Closed B4nan closed 2 years ago
No tests?
Nothing really changed, and existing tests are passing, so it should be enough. I will try to come up with some tests for the SDK integration. But more importantly, seems like the timeouting issue is not present when running via jest :/ Initially I tried to write a test case and things just magically worked (the task promise got cancelled after test finished, so once the timeout passed). When I ran it via node as a script directly, the issue was present 🤷 So it seems like it is impossible to write a test that would fail with the problem this is trying to solve, at least via jest.
Added test to demonstrate how this can be useful from SDK, also added tests to the SDK PR.
This is needed to deal with the timeouts in SDK. We do call
tryCancel()
even outside of the timeout handler - that is to allow early escape from the SDK functions that use the browser pool (and are wrapped insideaddTimeoutToPromise
call). ThetryCancel()
call outside of such handler is a no-op, so it is safe even if the pool would be used elsewhere.Related: https://github.com/apify/apify-js/issues/1102 https://github.com/apify/apify-js/issues/1216