trigger.dev icon indicating copy to clipboard operation
trigger.dev copied to clipboard

[TRI-1864] Calling io.logger. causes an auto-yield to happen. Logs shouldn't do that

Open matt-aitken opened this issue 2 years ago • 0 comments

Why is this happening

runTask allows you to divide your work into small chunks. That means you can avoid hitting serverless timeouts when you deploy.

It's important that we try and avoid you actually hitting one of these timeouts. If you do actually hit one then your running code will suddenly halt, which can leave some things in the middle of execution, like web requests you don't get the response from for example.

So, after a "Task" has completed we try and figure out if we have enough time to squeeze another one in, or if we should stop and re-execute the run function. When you're deployed we calculate your serverless timeout by running some tests on your server (we call it "probing"). But locally we have it set to 1 minute, which simulates a pretty generous timeout.

io.logger actually performs runTask under the hood. So it will cause an auto-yield if we think we're running out of time. Usually this wouldn't be a problem because you'd be dividing your work into small Tasks.

Solution

The io.logger functions shouldn't cause yielding to happen.

TRI-1864

matt-aitken avatar Jan 12 '24 22:01 matt-aitken