The SDK provides utility functions for logging output and controlling execution flow.
Methods
| Method | Description |
|---|
canvas.log(...args) | Log output (captured in execution results) |
canvas.delay(ms) | Wait for specified milliseconds |
canvas.log()
Log messages that are captured and returned in the execution results. Use this instead of console.log() to see output in the workflow UI.
Parameters
Any values to log. Objects are automatically stringified.
Example
canvas.log("Starting workflow...");
canvas.log("Found", companies.length, "companies");
canvas.log({ step: "complete", count: 42 });
Use canvas.log() liberally during development to debug your workflows. All logs are captured and displayed in the execution results.
canvas.delay()
Pause execution for a specified time. Useful for rate limiting or waiting between API calls.
Parameters
Milliseconds to wait. Maximum is 10,000 (10 seconds).
Example
// Wait 2 seconds between API calls
for (const company of companies) {
const result = await canvas.ai.research({
prompt: "Summarize this company",
data: company
});
await canvas.delay(2000); // Wait 2 seconds
}
The maximum delay is 10 seconds. Longer delays will be capped to prevent runaway executions.
Debugging Tips
Log Progress
const companies = await canvas.companies.find({
industries: ["Fintech"],
limit: 50,
});
canvas.log(`✓ Found ${companies.length} companies`);
const people = await canvas.people.search({
companies,
titles: ["CTO"],
});
canvas.log(`✓ Found ${people.length} people`);
const contacts = await canvas.contacts.enrich({ people });
canvas.log(`✓ Enriched ${contacts.length} contacts`);
return contacts;
Log Data Samples
// Log first item to inspect structure
canvas.log("Sample company:", companies[0]);
// Log specific fields
canvas.log("Industries found:", companies.map(c => c.industry).filter(Boolean));
Track Timing
const startTime = Date.now();
// ... do work ...
const elapsed = Date.now() - startTime;
canvas.log(`Completed in ${elapsed}ms`);