You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To prevent long-running or blocked worker threads from stalling the sync process, the Airdrop SDK implements a two-tier timeout mechanism.
250
+
251
+
- The **soft timeout** (default: 10 minutes, configurable) sends an exit message to the worker thread, allowing it to gracefully shut down via the `onTimeout` function.
252
+
- If the worker does not respond within the **hard timeout** (default: 13 minutes), it is forcefully terminated.
253
+
254
+
This mechanism ensures that the snap-in does not hang indefinitely, and the system can recover cleanly in case of stuck or slow code execution.
255
+
256
+
The most common reason for missed soft timeouts is code that blocks the Node.js event loop. This can prevent the worker thread from processing the exit signal, leading to a hard timeout and forced termination.
257
+
258
+
To keep the worker thread responsive and ensure soft timeout handling works as intended:
259
+
260
+
- Avoid long synchronous loops or CPU-heavy operations that block the event loop.
261
+
- Use `async/await` for I/O operations such as API calls or file reads.
262
+
- Add periodic async breaks in tight loops using `Promise.resolve()`, `setTimeout()`, or `setImmediate()`.
263
+
264
+
You can find examples of correct timeout-safe code in the [timeout-handling test suite](https://github.com/devrev/adaas-sdk/tree/main/src/tests/timeout-handling).
265
+
266
+
To test how your snap-in responds to timeouts, you can configure a shorter timeout using the `spawn` function:
0 commit comments