fix preserve mysql2 stream queries and native tracing events#140
Merged
sohankshirsagar merged 3 commits intomainfrom Mar 16, 2026
Merged
fix preserve mysql2 stream queries and native tracing events#140sohankshirsagar merged 3 commits intomainfrom
sohankshirsagar merged 3 commits intomainfrom
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Contributor
There was a problem hiding this comment.
1 issue found across 6 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/core/tracing/SpanUtils.ts">
<violation number="1" location="src/core/tracing/SpanUtils.ts:172">
P1: Don't throw when `stopRecordingChildSpans` is set in replay mode; this path is used to suppress nested instrumentation, and raising here will break replayed operations that intentionally run with child spans disabled.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
jy-tan
approved these changes
Mar 16, 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.


Summary
Fix mysql2 compatibility issues introduced by the recent mysql2
v3.20.0changes, especially the nativeTracingChannelwork added in sidorares/node-mysql2#4178.Our mysql2 instrumentation was relying on older callback-less
query()behavior. Afterv3.20.0, stream-style queries could route through mysql2's new internal tracing path, which broke the/test/stream-queryE2E flow and caused the request to hang before the query emitter deliveredend. This change restores stable stream-query behavior by taking control of the callback-less query command construction path inside our instrumentation, while also re-emitting equivalent nativemysql2:querytracing events so OTEL/APM subscribers still work.This PR also fixes constructor wrapping for mysql2 connection classes by preserving
new.targetviaReflect.construct(...). That was needed because mysql2v3.20.0also changed class relationships around pool connections, and naïvely callingnew OriginalConnection(...)from our wrapped constructor could break subclass instances likePoolConnectionby returning the wrong prototype chain.Changes
BaseConnection.createQuerywhen patching mysql2 so callback-less queries can be reconstructed without depending on wrapped constructorsquery()implementation for emitter-style queries and enqueue theQuerycommand directly viaaddCommand()result/fields/endEventEmitter-likemysql2:queryTracingChannelevents around the bypassed path so native subscribers still observe streaming queriesReflect.construct(OriginalConnection, args, constructTarget)so wrapped constructors preservenew.targetand return the correct subclass instancePoolConnection/constructor compatibility so subclass-specific methods and prototype behavior remain intact after mysql2 class-wrapping changesnode:diagnostics_channeland verifies nativemysql2:queryevents are emitted for streaming queries