fix(core): guard extractStreamIds against circular references#2687
Open
Osamaali313 wants to merge 1 commit into
Open
fix(core): guard extractStreamIds against circular references#2687Osamaali313 wants to merge 1 commit into
Osamaali313 wants to merge 1 commit into
Conversation
extractStreamIds recursively walks arrays/objects with no cycle guard. The hydrated observability data it traverses is produced by devalue, which preserves circular and repeated references, so a workflow step returning a self-referential value lands in the event log and later crashes the inspection paths (wf inspect CLI and the web dashboard) with RangeError: Maximum call stack size exceeded. Track visited containers in a WeakSet and skip already-seen ones. Behavior for acyclic inputs is unchanged. Adds regression tests for object and array cycles. Signed-off-by: Osamaali313 <86572800+Osamaali313@users.noreply.github.com>
🦋 Changeset detectedLatest commit: ffdd4b4 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
|
@Osamaali313 is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize 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.
Bug
extractStreamIds(packages/core/src/serialization-format.ts) recursively walks arrays and objects with no cycle guard:The data it walks is hydrated observability data produced by devalue, which explicitly preserves circular and repeated references (see
hydrateData→devalue.parse/unflatten). So a workflow step that returns a self-referential value (e.g.const o = {}; o.self = o; return o;) serializes fine, lands in the event log, and later crashes the inspection paths that callextractStreamIds—wf inspect(packages/cli/src/lib/inspect/hydration.ts) and the web dashboard (packages/web-shared/src/lib/hydration.ts) — withRangeError: Maximum call stack size exceeded.Reproduction (real code, vitest)
Two new tests fail on
mainwithRangeError: Maximum call stack size exceededand pass after the fix:(Confirmed devalue round-trips a cycle:
dv.parse(dv.stringify(a))witha.self = ayieldsround.self === round.)Fix
Track visited containers in a
WeakSetand skip already-seen ones. Behavior for acyclic inputs is unchanged (result de-duplication unaffected).Test
Adds object-cycle and array-cycle regression tests to
serialization-format.test.ts(describe('extractStreamIds')). Includes a changeset (@workflow/corepatch). Commit is DCO signed-off and signed (Verified).