Repository navigation
fix(core): start forwarded writable key lookup on first write - #3955
Closed
withkarann wants to merge 1 commit into
Closed
withkarann wants to merge 1 commit into
withkarann wants to merge 1 commit into
Conversation
Hydrating a forwarded writable started the encryption key lookup for the target run right away and stored the promise. Nothing awaited it until the first chunk was written, so when the lookup failed first, for example a run metadata request that timed out, the rejection was unhandled and took the process down. Wrap the lookup in a memoized thunk so it runs on the first write and its failure errors that stream instead. This matches how the readable side already defers its key lookup. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: withkarann <31102185+withkarann@users.noreply.github.com>
🦋 Changeset detectedLatest commit: 8863c2d The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
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 |
Contributor
|
@withkarann is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
2 of 3 tasks
Contributor
Author
|
Closing in favor of #4175, which carried this fix onto current main with the extra tests and the stable analysis. Thanks for the credit and for landing it. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Fixes #3935.
When a step's arguments or a run's return value contain a writable forwarded from another run, the reviver started the encryption key lookup for that run right away and stored the promise. Nothing awaited it until the first write. When the lookup failed first, for example when the fallback run metadata request timed out, the rejection had no handler and Node exited the process.
The lookup is now wrapped in a memoized thunk, so it starts on the first write and a failure errors that stream instead.
EncryptionKeyParamalready accepts a thunk, and the readable side already defers its key lookup the same way. Both reviver sites use the helper.One trade-off: forwarded writables without a public key (descriptors from older SDKs) now make the lookup requests on the first write instead of overlapping them with execution, and writables that are never written to make no requests at all. If keeping the prefetch matters more, the smaller alternative is to keep the eager call and mark the stored promise as handled. Happy to switch.
How did you test your changes?
New test next to the existing forwarded writable tests in
serialization.test.ts. It hydrates a forwarded writable with no deployment id and no public key, mocksruns.getto reject with aWorkflowWorldError(code: 'TIMEOUT'), and checks that nounhandledRejectionfires and no request is made before the first write, then that the writer'sclosedpromise rejects with the timeout as its cause. Onmainthe test fails because the request is made during hydration.PR Checklist - Required to merge
pnpm changesetwas run to create a changelog for this PRgit commit --signoffon your commits)@vercel/workflowin a comment once the PR is ready, and the above checklist is complete