dd-trace 5.37.0 → 5.37.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dd-trace",
3
- "version": "5.37.0",
3
+ "version": "5.37.1",
4
4
  "description": "Datadog APM tracing client for JavaScript",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
@@ -131,7 +131,7 @@
131
131
  "checksum": "^1.0.0",
132
132
  "cli-table3": "^0.6.3",
133
133
  "dotenv": "16.3.1",
134
- "esbuild": "0.16.12",
134
+ "esbuild": "^0.25.0",
135
135
  "eslint": "^9.19.0",
136
136
  "eslint-config-standard": "^17.1.0",
137
137
  "eslint-plugin-import": "^2.31.0",
@@ -1,11 +1,11 @@
1
1
  /* eslint-disable @stylistic/js/max-len */
2
2
  'use strict'
3
3
 
4
- const html = `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>You've been blocked</title><style>a,body,div,html,span{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}body{background:-webkit-radial-gradient(26% 19%,circle,#fff,#f4f7f9);background:radial-gradient(circle at 26% 19%,#fff,#f4f7f9);display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:center;align-content:center;width:100%;min-height:100vh;line-height:1;flex-direction:column}p{display:block}main{text-align:center;flex:1;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:center;align-content:center;flex-direction:column}p{font-size:18px;line-height:normal;color:#646464;font-family:sans-serif;font-weight:400}a{color:#4842b7}footer{width:100%;text-align:center}footer p{font-size:16px}</style></head><body><main><p>Sorry, you cannot access this page. Please contact the customer service team.</p></main><footer><p>Security provided by <a href="https://www.datadoghq.com/product/security-platform/application-security-monitoring/" target="_blank">Datadog</a></p></footer></body></html>`
4
+ const html = '<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>You\'ve been blocked</title><style>a,body,div,html,span{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}body{background:-webkit-radial-gradient(26% 19%,circle,#fff,#f4f7f9);background:radial-gradient(circle at 26% 19%,#fff,#f4f7f9);display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:center;align-content:center;width:100%;min-height:100vh;line-height:1;flex-direction:column}p{display:block}main{text-align:center;flex:1;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:center;align-content:center;flex-direction:column}p{font-size:18px;line-height:normal;color:#646464;font-family:sans-serif;font-weight:400}a{color:#4842b7}footer{width:100%;text-align:center}footer p{font-size:16px}</style></head><body><main><p>Sorry, you cannot access this page. Please contact the customer service team.</p></main><footer><p>Security provided by <a href="https://www.datadoghq.com/product/security-platform/application-security-monitoring/" target="_blank">Datadog</a></p></footer></body></html>'
5
5
 
6
- const json = `{"errors":[{"title":"You've been blocked","detail":"Sorry, you cannot access this page. Please contact the customer service team. Security provided by Datadog."}]}`
6
+ const json = '{"errors":[{"title":"You\'ve been blocked","detail":"Sorry, you cannot access this page. Please contact the customer service team. Security provided by Datadog."}]}'
7
7
 
8
- const graphqlJson = `{"errors":[{"message":"You've been blocked","extensions":{"detail":"Sorry, you cannot perform this operation. Please contact the customer service team. Security provided by Datadog."}}]}`
8
+ const graphqlJson = '{"errors":[{"message":"You\'ve been blocked","extensions":{"detail":"Sorry, you cannot perform this operation. Please contact the customer service team. Security provided by Datadog."}}]}'
9
9
 
10
10
  module.exports = {
11
11
  html,
@@ -70,7 +70,7 @@ class TestVisDynamicInstrumentation {
70
70
  env: {
71
71
  ...process.env,
72
72
  DD_TRACE_ENABLED: 0,
73
- DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED: 0
73
+ DD_TEST_FAILED_TEST_REPLAY_ENABLED: 0
74
74
  },
75
75
  workerData: {
76
76
  config: config.serialize(),
@@ -1144,7 +1144,7 @@ class Config {
1144
1144
  DD_CIVISIBILITY_FLAKY_RETRY_COUNT,
1145
1145
  DD_TEST_SESSION_NAME,
1146
1146
  DD_AGENTLESS_LOG_SUBMISSION_ENABLED,
1147
- DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED,
1147
+ DD_TEST_FAILED_TEST_REPLAY_ENABLED,
1148
1148
  DD_TEST_MANAGEMENT_ENABLED,
1149
1149
  DD_TEST_MANAGEMENT_ATTEMPT_TO_FIX_RETRIES
1150
1150
  } = process.env
@@ -1164,7 +1164,7 @@ class Config {
1164
1164
  this._setBoolean(calc, 'isManualApiEnabled', !isFalse(this._isCiVisibilityManualApiEnabled()))
1165
1165
  this._setString(calc, 'ciVisibilityTestSessionName', DD_TEST_SESSION_NAME)
1166
1166
  this._setBoolean(calc, 'ciVisAgentlessLogSubmissionEnabled', isTrue(DD_AGENTLESS_LOG_SUBMISSION_ENABLED))
1167
- this._setBoolean(calc, 'isTestDynamicInstrumentationEnabled', isTrue(DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED))
1167
+ this._setBoolean(calc, 'isTestDynamicInstrumentationEnabled', !isFalse(DD_TEST_FAILED_TEST_REPLAY_ENABLED))
1168
1168
  this._setBoolean(calc, 'isServiceUserProvided', !!this._env.service)
1169
1169
  this._setBoolean(calc, 'isTestManagementEnabled', !isFalse(DD_TEST_MANAGEMENT_ENABLED))
1170
1170
  this._setValue(calc,
@@ -31,9 +31,9 @@ async function addBreakpoint (probe) {
31
31
  probe.nsBetweenSampling = BigInt(1 / snapshotsPerSecond * 1e9)
32
32
  probe.lastCaptureNs = 0n
33
33
 
34
- // TODO: Inbetween `await session.post('Debugger.enable')` and here, the scripts are parsed and cached.
35
- // Maybe there's a race condition here or maybe we're guraenteed that `await session.post('Debugger.enable')` will
36
- // not continue untill all scripts have been parsed?
34
+ // Warning: The code below relies on undocumented behavior of the inspector!
35
+ // It expects that `await session.post('Debugger.enable')` will wait for all loaded scripts to be emitted as
36
+ // `Debugger.scriptParsed` events. If this ever changes, we will have a race condition!
37
37
  const script = findScriptFromPartialPath(file)
38
38
  if (!script) throw new Error(`No loaded script found for ${file} (probe: ${probe.id}, version: ${probe.version})`)
39
39
  const { url, scriptId, sourceMapURL, source } = script
@@ -7,6 +7,7 @@ const { SourceMapConsumer } = require('source-map')
7
7
 
8
8
  const cache = new Map()
9
9
  let cacheTimer = null
10
+ let cacheTimerLastSet = 0
10
11
 
11
12
  const self = module.exports = {
12
13
  async loadSourceMap (dir, url) {
@@ -33,13 +34,26 @@ const self = module.exports = {
33
34
  }
34
35
  }
35
36
 
37
+ // TODO: Remove if-statement around `setTimeout` below once it's safe to do so.
38
+ //
39
+ // This is a workaround for, what seems like a bug in Node.js core, that seems to trigger when, among other things, a
40
+ // lot of timers are being created very rapidly. This makes the call to `setTimeout` throw an error from within
41
+ // `AsyncLocalStorage._propagate` with the following error message:
42
+ //
43
+ // TypeError: Cannot read properties of undefined (reading 'Symbol(kResourceStore)')
44
+ //
45
+ // Source: https://github.com/nodejs/node/blob/v18.20.6/lib/async_hooks.js#L312
36
46
  function cacheIt (key, value) {
37
- clearTimeout(cacheTimer)
38
- cacheTimer = setTimeout(function () {
39
- // Optimize for app boot, where a lot of reads might happen
40
- // Clear cache a few seconds after it was last used
41
- cache.clear()
42
- }, 10_000).unref()
47
+ const now = Date.now()
48
+ if (now > cacheTimerLastSet + 1_000) {
49
+ clearTimeout(cacheTimer)
50
+ cacheTimer = setTimeout(function () {
51
+ // Optimize for app boot, where a lot of reads might happen
52
+ // Clear cache a few seconds after it was last used
53
+ cache.clear()
54
+ }, 10_000).unref()
55
+ cacheTimerLastSet = now
56
+ }
43
57
  cache.set(key, value)
44
58
  return value
45
59
  }
@@ -202,15 +202,15 @@ module.exports = class CiPlugin extends Plugin {
202
202
  configure (config, shouldGetEnvironmentData = true) {
203
203
  super.configure(config)
204
204
 
205
+ if (!shouldGetEnvironmentData) {
206
+ return
207
+ }
208
+
205
209
  if (config.isTestDynamicInstrumentationEnabled && !this.di) {
206
210
  const testVisibilityDynamicInstrumentation = require('../ci-visibility/dynamic-instrumentation')
207
211
  this.di = testVisibilityDynamicInstrumentation
208
212
  }
209
213
 
210
- if (!shouldGetEnvironmentData) {
211
- return
212
- }
213
-
214
214
  this.testEnvironmentMetadata = getTestEnvironmentMetadata(this.constructor.id, this.config)
215
215
 
216
216
  const {