Fix Live Debugger returned arrow instrumentation#442
Draft
watson wants to merge 1 commit into
Draft
Conversation
This was referenced Jun 29, 2026
Contributor
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
🎉 All green!🧪 All tests passed 🔗 Commit SHA: 0160533 | Docs | Datadog PR Page | Give us feedback! |
When a block-bodied function returned an anonymous expression-bodied arrow, Live Debugger could queue the outer return wrapper at the same byte offset as the inner arrow suffix. MagicString emitted the outer tail inside the inner arrow instrumentation, producing invalid JavaScript. Anchor the return-wrapper tail on the right side of the shared offset so the inner arrow suffix closes first. Add regression coverage for returned arrows, including JSX mapping, while asserting the output remains instrumented.
503521e to
e5064e7
Compare
99d8aed to
0160533
Compare
This was referenced Jul 3, 2026
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.

What and why?
Fix a Live Debugger transform bug that could emit invalid JavaScript when instrumenting a block-bodied function that returns an anonymous expression-bodied arrow.
For example, this input:
Could generate output shaped like this before the fix, formatted here for readability:
In all-functions mode, both the inner arrow suffix and the outer return wrapper could be inserted at the same byte offset. The outer return-capture tail landed before the inner arrow suffix closed, leaving invalid JavaScript. Named-only mode avoided the issue by skipping the anonymous inner arrow.
How?
Change the outer
return EXPRwrapper tail fromappendLefttoappendRightatret.argEnd, so an inner expression-body arrow suffix already queued at that offset is emitted first and closes the inner instrumentation before the outer return capture tail.Add regression cases for block-bodied arrows and function declarations returning expression-bodied arrows, including a JSX mapping case, plus a block-bodied inner arrow control. The table continues to parse transformed output and now also asserts return instrumentation is still present.