Accept an AbortSignal in onRpcBroken and cleanup registrations when stubs are disposed - #250
Accept an AbortSignal in onRpcBroken and cleanup registrations when stubs are disposed#250srikrsna wants to merge 1 commit into
AbortSignal in onRpcBroken and cleanup registrations when stubs are disposed#250Conversation
…en the stubs are disposed
🦋 Changeset detectedLatest commit: f956cb4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
|
/bonk review this |
Review:
|
|
Review posted to PR #250: #250 (comment) SummaryI reviewed the full diff, built the project, and ran the Verdict: LGTM. The change is clean, well-scoped, and thoroughly tested. Key findings:
Non-blocking observations I noted: a small amount of stale-but-harmless listener state left on the entry after One environment note: the default |
|
@srikrsna Bonk workflow was cancelled. View workflow run · To retry, trigger Bonk again. |
|
No toolchain available, but the code analysis is complete. Summary of reviewThe PR adds an optional
The only observations are non-blocking and already noted in the existing thread (stale-but-harmless I was unable to run the test suite (dependencies not installed in this environment), but the signal/ LGTM |
| // Don't throw back into the RPC system. Treat this as an unhandled rejection. | ||
| Promise.resolve(err); |
There was a problem hiding this comment.
Nit: outside the scope of this PR, but noticed we had Promise.resolve(err) with comment // Treat this as an unhandled rejection. Should this be Promise.reject(err) like in disposeRpcTarget (line 1877)?
|
I think I prefer the disposable:
So I'd prefer the disposable API over the AbortSignal API. However, there may be one other alternative to explore: What if we just don't add any new API here at all, and tell people to dispose the stub when they want the callback to be unregistered? If someone wants the ability to unregister a callback without disposing the stub, they can simply |
Closes #210 and #234
Adds an optional second parameter to
onRpcBroken, with an optionalsignal. Arguably it could just be the signal, since I don't see us adding any more options. But this leaves room if we do.#234 proposes that
onRpcBrokenreturn aDisposable. That lines up with the rest of the API, but it implies to the caller they're holding something that needs to be disposed. I don't know of a lint rule that enforces that, but I wouldn't be surprised if one exists.I went with a signal for a few reasons:
This PR also removes callbacks when a stub is disposed.