-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DI] Add source map support #5205
Conversation
Overall package sizeSelf size: 8.69 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | @datadog/libdatadog | 0.4.0 | 29.44 MB | 29.44 MB | | @datadog/native-appsec | 8.4.0 | 19.25 MB | 19.26 MB | | @datadog/native-iast-taint-tracking | 3.3.0 | 13.77 MB | 13.78 MB | | @datadog/pprof | 5.5.1 | 9.79 MB | 10.17 MB | | protobufjs | 7.2.5 | 2.77 MB | 5.16 MB | | @datadog/native-iast-rewriter | 2.8.0 | 2.6 MB | 2.74 MB | | @opentelemetry/core | 1.14.0 | 872.87 kB | 1.47 MB | | @datadog/native-metrics | 3.1.0 | 1.06 MB | 1.46 MB | | @opentelemetry/api | 1.8.0 | 1.21 MB | 1.21 MB | | import-in-the-middle | 1.11.2 | 112.74 kB | 835.4 kB | | source-map | 0.7.4 | 226 kB | 226 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | lru-cache | 7.18.3 | 133.92 kB | 133.92 kB | | pprof-format | 2.1.0 | 111.69 kB | 111.69 kB | | @datadog/sketches-js | 2.1.0 | 109.9 kB | 109.9 kB | | lodash.sortby | 4.7.0 | 75.76 kB | 75.76 kB | | ignore | 5.3.2 | 53.63 kB | 53.63 kB | | shell-quote | 1.8.1 | 44.96 kB | 44.96 kB | | istanbul-lib-coverage | 3.2.0 | 29.34 kB | 29.34 kB | | rfdc | 1.3.1 | 25.21 kB | 25.21 kB | | @isaacs/ttlcache | 1.4.1 | 25.2 kB | 25.2 kB | | tlhunter-sorted-set | 0.1.0 | 24.94 kB | 24.94 kB | | limiter | 1.1.5 | 23.17 kB | 23.17 kB | | dc-polyfill | 0.1.4 | 23.1 kB | 23.1 kB | | retry | 0.13.1 | 18.85 kB | 18.85 kB | | semifies | 1.0.0 | 15.84 kB | 15.84 kB | | jest-docblock | 29.7.0 | 8.99 kB | 12.76 kB | | crypto-randomuuid | 1.0.0 | 11.18 kB | 11.18 kB | | ttl-set | 1.0.0 | 4.61 kB | 9.69 kB | | path-to-regexp | 0.1.12 | 6.6 kB | 6.6 kB | | koalas | 1.0.2 | 6.47 kB | 6.47 kB | | module-details-from-path | 1.0.3 | 4.47 kB | 4.47 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5205 +/- ##
==========================================
- Coverage 81.24% 81.22% -0.03%
==========================================
Files 487 487
Lines 21703 21709 +6
==========================================
Hits 17633 17633
- Misses 4070 4076 +6 ☔ View full report in Codecov by Sentry. |
e5d2e4a
to
0e13626
Compare
BenchmarksBenchmark execution time: 2025-02-13 10:44:06 Comparing candidate commit f020cab in PR branch Found 58 performance improvements and 1 performance regressions! Performance is the same for 848 metrics, 26 unstable metrics. scenario:debugger-enabled-but-breakpoint-not-hit-18
scenario:debugger-enabled-but-breakpoint-not-hit-20
scenario:debugger-enabled-but-breakpoint-not-hit-22
scenario:debugger-line-probe-with-snapshot-default-18
scenario:debugger-line-probe-with-snapshot-default-20
scenario:debugger-line-probe-with-snapshot-default-22
scenario:debugger-line-probe-with-snapshot-minimal-18
scenario:debugger-line-probe-with-snapshot-minimal-20
scenario:debugger-line-probe-with-snapshot-minimal-22
scenario:debugger-line-probe-without-snapshot-18
scenario:debugger-line-probe-without-snapshot-20
scenario:debugger-line-probe-without-snapshot-22
scenario:plugin-graphql-with-async-hooks-18
scenario:plugin-graphql-with-async-hooks-20
|
0e13626
to
76de624
Compare
Datadog ReportBranch report: ✅ 0 Failed, 630 Passed, 0 Skipped, 15m 49.97s Total Time |
cf1d731
to
d354b44
Compare
try { | ||
lineNumber = await processScriptWithInlineSourceMap({ file, line, sourceMapURL }) | ||
lineNumber = await getSourceMappedLine(url, source, line, sourceMapURL) | ||
} catch (err) { | ||
log.error('Error processing script with inline source map', err) | ||
log.error('Error processing script with source map', err) | ||
} | ||
if (lineNumber === null) { | ||
log.error('Could not find generated position for %s:%s', url, line) | ||
lineNumber = line | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully the new algorithm is more stable in regards to finding the right line. If we still can't find it, shouldn't this code just throw so it's aborted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to avoid throwing so that the next test may have a chance to still set a probe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't you then at least return early and not try to attach the breakpoint to a line number that is most likely incorrect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you try-catch around the code that adds the breakpoint takes care of that for you, but if you don't think it will work, I think it makes the purpose of the code more readable if we return early in that case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't you then at least return early and not try to attach the breakpoint to a line number that is most likely incorrect?
you're right. I remember finding a situation where the source map was there, processScriptWithInlineSourceMap
failed, but setting the probe in the original line number worked 😓. I'm definitely missing something here
d354b44
to
b29d37f
Compare
Resolve probe location using source maps if available
b29d37f
to
7962024
Compare
7962024
to
f020cab
Compare
while (Date.now() < waitUntil) { | ||
// TODO: To avoid a race condition, we should wait until `probeInformation.setProbePromise` has resolved. | ||
// However, Mocha doesn't have a mechanism for waiting asyncrounously here, so for now, we'll have to | ||
// fall back to a fixed syncronous delay. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this makes sense and it's likely a good tradeoff, as the user opts in to having a debugger probe in their test. If they're debugging a problematic test, they're likely OK paying a 200ms active wait, as the test is likely to take much longer.
Thanks for this idea!
// TODO: To avoid a race condition, we should wait until `probeInformation.setProbePromise` has resolved. | ||
// However, Cucumber doesn't have a mechanism for waiting asyncrounously here, so for now, we'll have to | ||
// fall back to a fixed syncronous delay. | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for worrying about test optimization code and for finding this nice trick 😄 . LGTM!
What does this PR do?
Resolve probe location using a source map if available.
Motivation
A lot of users will transpile their source code before deploying. For example if they develop in TypeScript. Without source map support, these users will not be able to use Dynamic Instrumentation reliably, as the probe file/line might not match a file/line in the running app.
Plugin Checklist
Additional Notes