Repository navigation
fix(js-sdk): treat a watch stopped via handle.stop() as a clean exit #1896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
BlueX888
wants to merge
1
commit into
e2b-dev:main
from
BlueX888:fix/prep-watch-stop-onexit-fake-timeout-error
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "e2b": patch | ||
| --- | ||
|
|
||
| Fire the filesystem watch `onExit` callback with no error when the watch is stopped with `handle.stop()`. Stopping a watch aborts the underlying request, which the transport surfaces as a canceled error — the same code a request timeout maps to — so every clean, user-initiated stop reported a `TimeoutError` telling the user to raise `requestTimeoutMs`. The cancellation `stop()` itself triggers is now treated as the clean end of the watch, matching the Python SDK; a cancellation from anywhere else (e.g. a request timeout) still fires `onExit` with the error. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
T-46 — a caller-provided
signalmust still cancel an in-flight watch, with its failure surfaced toonExit. Ifopts.signalaborts first, thenhandle.stop()runs before the async iterator handles the resultingCode.Canceled,this.stoppedis true and this branch silently callsonExit()as though stop caused the cancellation. That also hides the actionable timeout error when the caller usesAbortSignal.timeout(...)(T-64). Track the cause of the first abort, rather than whetherstop()was ever called: e.g. let the cleanup callback report!controller.signal.abortedbefore it aborts, and only suppressCode.Canceledwhen that report says stop initiated the abort. Please cover signal-aborts-then-stop in the watch tests.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed against the current diff.
stoppedrecords whetherstop()was called at any point, not which signal initiated the cancellation. If the caller’s signal aborts first andstop()follows before the iterator catchesCode.Canceled, the error is incorrectly suppressed. The fix needs to record the first abort cause and treat only stop-initiated cancellation as a clean exit, with a regression for caller-abort-then-stop (including timeout signals). This remains outstanding in the current patch.