From f6ec008977907c691a23f81508631f3c4257eee3 Mon Sep 17 00:00:00 2001 From: Stephen Belanger Date: Fri, 27 Mar 2026 05:30:09 +0800 Subject: [PATCH] fix(auto-instrumentation): Upgrade @apm-js-collab/code-transformer to v0.12.0 - Bump version range to ^0.12.0. v0.12.0 is a JS rewrite (replacing the WASM transformer) that fixes Promise subclass preservation, restoring APIPromise.withResponse() support under auto-instrumentation. - Fix ESM loader hook to pass the actual module type (esm/cjs/unknown) from the Node.js loader format instead of always passing "unknown", which caused CJS require() to be injected into ESM files. - Remove tracePromise assertions from transformation tests (implementation detail of the old WASM output; new JS version uses runStores instead). - Add @apm-js-collab/* to minimumReleaseAgeExclude so pnpm can install v0.12.0 during the 3-day release age window. Co-Authored-By: Claude Sonnet 4.6 --- js/package.json | 4 +- .../auto-instrumentations/loader/esm-hook.mts | 8 +- .../transformation.test.ts | 5 - pnpm-lock.yaml | 112 +++++++++++------- pnpm-workspace.yaml | 2 + 5 files changed, 79 insertions(+), 52 deletions(-) diff --git a/js/package.json b/js/package.json index 4b8fa173c..005bd08d6 100644 --- a/js/package.json +++ b/js/package.json @@ -199,7 +199,7 @@ }, "dependencies": { "@ai-sdk/provider": "^1.1.3", - "@apm-js-collab/code-transformer": "^0.9.0", + "@apm-js-collab/code-transformer": "^0.12.0", "@next/env": "^14.2.3", "@vercel/functions": "^1.0.2", "ajv": "^8.17.1", @@ -209,7 +209,7 @@ "cli-progress": "^3.12.0", "cli-table3": "^0.6.5", "cors": "^2.8.5", - "dc-browser": "^1.0.3", + "dc-browser": "^1.0.4", "dotenv": "^16.4.5", "esbuild": "^0.27.0", "eventsource-parser": "^1.1.2", diff --git a/js/src/auto-instrumentations/loader/esm-hook.mts b/js/src/auto-instrumentations/loader/esm-hook.mts index 4f6d16a28..c5af87183 100644 --- a/js/src/auto-instrumentations/loader/esm-hook.mts +++ b/js/src/auto-instrumentations/loader/esm-hook.mts @@ -86,9 +86,15 @@ export async function load(url: string, context: any, nextLoad: Function) { if (code) { const transformer = transformers.get(url); try { + const moduleType = + result.format === "module" + ? "esm" + : result.format === "commonjs" + ? "cjs" + : "unknown"; const transformedCode = transformer.transform( code.toString("utf8"), - "unknown", + moduleType, ); result.source = transformedCode?.code; result.shortCircuit = true; diff --git a/js/tests/auto-instrumentations/transformation.test.ts b/js/tests/auto-instrumentations/transformation.test.ts index dee079bcf..c51f12758 100644 --- a/js/tests/auto-instrumentations/transformation.test.ts +++ b/js/tests/auto-instrumentations/transformation.test.ts @@ -68,7 +68,6 @@ describe("Orchestrion Transformation Tests", () => { // Verify orchestrion transformed the code expect(output).toContain("tracingChannel"); expect(output).toContain("orchestrion:openai:chat.completions.create"); - expect(output).toContain("tracePromise"); }); it("should bundle dc-browser module when browser: true", async () => { @@ -149,7 +148,6 @@ describe("Orchestrion Transformation Tests", () => { // Verify orchestrion transformed the code expect(output).toContain("tracingChannel"); expect(output).toContain("orchestrion:openai:chat.completions.create"); - expect(output).toContain("tracePromise"); }); it("should bundle dc-browser module when browser: true", async () => { @@ -244,7 +242,6 @@ describe("Orchestrion Transformation Tests", () => { expect(errors).toHaveLength(0); expect(output).toContain("tracingChannel"); expect(output).toContain("orchestrion:openai:chat.completions.create"); - expect(output).toContain("tracePromise"); }); it("should bundle dc-browser module when browser: true", async () => { @@ -334,7 +331,6 @@ describe("Orchestrion Transformation Tests", () => { expect(errors).toHaveLength(0); expect(output).toContain("tracingChannel"); expect(output).toContain("orchestrion:openai:chat.completions.create"); - expect(output).toContain("tracePromise"); }); it("should bundle dc-browser polyfill when browser: true (turbopack loader-only mode)", async () => { @@ -418,7 +414,6 @@ describe("Orchestrion Transformation Tests", () => { // Verify orchestrion transformed the code expect(output).toContain("tracingChannel"); expect(output).toContain("orchestrion:openai:chat.completions.create"); - expect(output).toContain("tracePromise"); }); it("should bundle dc-browser module when browser: true", async () => { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 93c8da126..c8f720055 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -280,8 +280,8 @@ importers: specifier: ^1.1.3 version: 1.1.3 '@apm-js-collab/code-transformer': - specifier: ^0.9.0 - version: 0.9.0 + specifier: ^0.12.0 + version: 0.12.0 '@next/env': specifier: ^14.2.3 version: 14.2.3 @@ -310,8 +310,8 @@ importers: specifier: ^2.8.5 version: 2.8.5 dc-browser: - specifier: ^1.0.3 - version: 1.0.3 + specifier: ^1.0.4 + version: 1.0.4 dotenv: specifier: ^16.4.5 version: 16.4.5 @@ -417,10 +417,10 @@ importers: version: 9.0.7 '@typescript-eslint/eslint-plugin': specifier: ^8.49.0 - version: 8.50.0(@typescript-eslint/parser@8.50.0(eslint@9.39.3(jiti@2.6.1))(typescript@5.4.4))(eslint@9.39.3(jiti@2.6.1))(typescript@5.4.4) + version: 8.50.0(@typescript-eslint/parser@8.50.0(eslint@9.39.4(jiti@2.6.1))(typescript@5.4.4))(eslint@9.39.4(jiti@2.6.1))(typescript@5.4.4) '@typescript-eslint/parser': specifier: ^8.49.0 - version: 8.50.0(eslint@9.39.3(jiti@2.6.1))(typescript@5.4.4) + version: 8.50.0(eslint@9.39.4(jiti@2.6.1))(typescript@5.4.4) ai: specifier: ^6.0.0 version: 6.0.37(zod@3.25.76) @@ -435,7 +435,7 @@ importers: version: 7.0.3 eslint-plugin-node-import: specifier: ^1.0.5 - version: 1.0.5(eslint@9.39.3(jiti@2.6.1)) + version: 1.0.5(eslint@9.39.4(jiti@2.6.1)) jiti: specifier: ^2.6.1 version: 2.6.1 @@ -680,8 +680,8 @@ packages: peerDependencies: openapi-types: '>=7' - '@apm-js-collab/code-transformer@0.9.0': - resolution: {integrity: sha512-cfHtufVUBKJz6se/tQBJqizgoot5AOxhVy5B9Cuo493p6b7hXKBEIi6tcZEbr4XwN1VnV9JZOu52MMTCOCSBMw==} + '@apm-js-collab/code-transformer@0.12.0': + resolution: {integrity: sha512-5F2ob4cMYezbaUGAk+YltbDvb9BFIghN92ubct9Ho/0MFx4FkChCxYV99NkU6Kx+RAgaqBV6yxKuWreQ6K8SOw==} '@babel/code-frame@7.24.7': resolution: {integrity: sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==} @@ -1533,8 +1533,8 @@ packages: resolution: {integrity: sha512-q1mjIoW1VX4IvSocvM/vbTiveKC4k9eLrajNEuSsmjymSDEbpGddtpfOoN7YGAqBK3NG+uqo8ia4PDTt8buCYA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@eslint/js@9.39.3': - resolution: {integrity: sha512-1B1VkCq6FuUNlQvlBYb+1jDu/gV297TIs/OeiaSR9l1H27SVW55ONE1e1Vp16NqP683+xEGzxYtv4XCiDPaQiw==} + '@eslint/js@9.39.4': + resolution: {integrity: sha512-nE7DEIchvtiFTwBw4Lfbu59PG+kCofhjsKaCWzxTpt4lfRjRMqG6uMBzKXuEcyXhOHoUp9riAm7/aWYGhXZ9cw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} '@eslint/object-schema@2.1.7': @@ -2659,8 +2659,8 @@ packages: resolution: {integrity: sha512-iX1mgmGrXdANhhITbpp2QQM2fGehBse9LbTf0sidWK6yg/NE+uhV5dfU1g6EYPlcReYmkE9QLPq/2irKAmtS9w==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/types@8.57.1': - resolution: {integrity: sha512-S29BOBPJSFUiblEl6RzPPjJt6w25A6XsBqRVDt53tA/tlL8q7ceQNZHTjPeONt/3S7KRI4quk+yP9jK2WjBiPQ==} + '@typescript-eslint/types@8.58.0': + resolution: {integrity: sha512-O9CjxypDT89fbHxRfETNoAnHj/i6IpRK0CvbVN3qibxlLdo5p5hcLmUuCCrHMpxiWSwKyI8mCP7qRNYuOJ0Uww==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} '@typescript-eslint/typescript-estree@8.50.0': @@ -2986,6 +2986,10 @@ packages: resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} engines: {node: '>=12'} + astring@1.9.0: + resolution: {integrity: sha512-LElXdjswlqjWrPpJFg1Fx4wpkOCxj1TDHlSV4PlaRxHGWko024xICaa97ZkMfs6DRKlCguiAI+rbXv5GWwXIkg==} + hasBin: true + async@3.2.5: resolution: {integrity: sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==} @@ -3333,8 +3337,8 @@ packages: csstype@3.2.3: resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==} - dc-browser@1.0.3: - resolution: {integrity: sha512-B2PJFzWouEPzc+jLo+yTgUXaVz0eZjVsfKX9CnUDzezsluxOKOjllBpw0EJJ1KNJGnNzKpZ4dDYtd+jVp0KRNA==} + dc-browser@1.0.4: + resolution: {integrity: sha512-7oEtnzNlcE+hr4OvO3GR6Gndgw8BhW+wKOEwMqSleyY7N29jbAxzyW5BaJl7qBCw+6OIxfMWtY0T+6dxq8RWLw==} debug@2.6.9: resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==} @@ -3549,8 +3553,8 @@ packages: jiti: optional: true - eslint@9.39.3: - resolution: {integrity: sha512-VmQ+sifHUbI/IcSopBCF/HO3YiHQx/AVd3UVyYL6weuwW+HvON9VYn5l6Zl1WZzPWXPNZrSQpxwkkZ/VuvJZzg==} + eslint@9.39.4: + resolution: {integrity: sha512-XoMjdBOwe/esVgEvLmNsD3IRHkm7fbKIUGvrleloJXUZgDHig2IPWNniv+GwjyJXzuNqVjlr5+4yVUZjycJwfQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} hasBin: true peerDependencies: @@ -4474,6 +4478,10 @@ packages: resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} engines: {node: '>= 8'} + meriyah@6.1.4: + resolution: {integrity: sha512-Sz8FzjzI0kN13GK/6MVEsVzMZEPvOhnmmI1lU5+/1cGOiK3QUahntrNNtdVeihrO7t9JpoH75iMNXg6R6uWflQ==} + engines: {node: '>=18.0.0'} + methods@1.1.2: resolution: {integrity: sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==} engines: {node: '>= 0.6'} @@ -5088,6 +5096,9 @@ packages: secure-json-parse@2.7.0: resolution: {integrity: sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==} + semifies@1.0.0: + resolution: {integrity: sha512-xXR3KGeoxTNWPD4aBvL5NUpMTT7WMANr3EWnaS190QVkY52lqqcVRD7Q05UVbBhiWDGWMlJEUam9m7uFFGVScw==} + semver@6.3.1: resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} hasBin: true @@ -6147,7 +6158,14 @@ snapshots: call-me-maybe: 1.0.2 openapi-types: 12.1.3 - '@apm-js-collab/code-transformer@0.9.0': {} + '@apm-js-collab/code-transformer@0.12.0': + dependencies: + '@types/estree': 1.0.8 + astring: 1.9.0 + esquery: 1.7.0 + meriyah: 6.1.4 + semifies: 1.0.0 + source-map: 0.6.1 '@babel/code-frame@7.24.7': dependencies: @@ -6994,14 +7012,14 @@ snapshots: eslint: 9.39.2(jiti@2.6.1) eslint-visitor-keys: 3.4.3 - '@eslint-community/eslint-utils@4.9.0(eslint@9.39.3(jiti@2.6.1))': + '@eslint-community/eslint-utils@4.9.0(eslint@9.39.4(jiti@2.6.1))': dependencies: - eslint: 9.39.3(jiti@2.6.1) + eslint: 9.39.4(jiti@2.6.1) eslint-visitor-keys: 3.4.3 - '@eslint-community/eslint-utils@4.9.1(eslint@9.39.3(jiti@2.6.1))': + '@eslint-community/eslint-utils@4.9.1(eslint@9.39.4(jiti@2.6.1))': dependencies: - eslint: 9.39.3(jiti@2.6.1) + eslint: 9.39.4(jiti@2.6.1) eslint-visitor-keys: 3.4.3 '@eslint-community/regexpp@4.12.2': {} @@ -7060,7 +7078,7 @@ snapshots: '@eslint/js@9.39.2': {} - '@eslint/js@9.39.3': {} + '@eslint/js@9.39.4': {} '@eslint/object-schema@2.1.7': {} @@ -8368,15 +8386,15 @@ snapshots: dependencies: '@types/yargs-parser': 21.0.3 - '@typescript-eslint/eslint-plugin@8.50.0(@typescript-eslint/parser@8.50.0(eslint@9.39.3(jiti@2.6.1))(typescript@5.4.4))(eslint@9.39.3(jiti@2.6.1))(typescript@5.4.4)': + '@typescript-eslint/eslint-plugin@8.50.0(@typescript-eslint/parser@8.50.0(eslint@9.39.4(jiti@2.6.1))(typescript@5.4.4))(eslint@9.39.4(jiti@2.6.1))(typescript@5.4.4)': dependencies: '@eslint-community/regexpp': 4.12.2 - '@typescript-eslint/parser': 8.50.0(eslint@9.39.3(jiti@2.6.1))(typescript@5.4.4) + '@typescript-eslint/parser': 8.50.0(eslint@9.39.4(jiti@2.6.1))(typescript@5.4.4) '@typescript-eslint/scope-manager': 8.50.0 - '@typescript-eslint/type-utils': 8.50.0(eslint@9.39.3(jiti@2.6.1))(typescript@5.4.4) - '@typescript-eslint/utils': 8.50.0(eslint@9.39.3(jiti@2.6.1))(typescript@5.4.4) + '@typescript-eslint/type-utils': 8.50.0(eslint@9.39.4(jiti@2.6.1))(typescript@5.4.4) + '@typescript-eslint/utils': 8.50.0(eslint@9.39.4(jiti@2.6.1))(typescript@5.4.4) '@typescript-eslint/visitor-keys': 8.50.0 - eslint: 9.39.3(jiti@2.6.1) + eslint: 9.39.4(jiti@2.6.1) ignore: 7.0.5 natural-compare: 1.4.0 ts-api-utils: 2.1.0(typescript@5.4.4) @@ -8384,14 +8402,14 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.50.0(eslint@9.39.3(jiti@2.6.1))(typescript@5.4.4)': + '@typescript-eslint/parser@8.50.0(eslint@9.39.4(jiti@2.6.1))(typescript@5.4.4)': dependencies: '@typescript-eslint/scope-manager': 8.50.0 '@typescript-eslint/types': 8.50.0 '@typescript-eslint/typescript-estree': 8.50.0(typescript@5.4.4) '@typescript-eslint/visitor-keys': 8.50.0 debug: 4.4.3 - eslint: 9.39.3(jiti@2.6.1) + eslint: 9.39.4(jiti@2.6.1) typescript: 5.4.4 transitivePeerDependencies: - supports-color @@ -8414,13 +8432,13 @@ snapshots: dependencies: typescript: 5.4.4 - '@typescript-eslint/type-utils@8.50.0(eslint@9.39.3(jiti@2.6.1))(typescript@5.4.4)': + '@typescript-eslint/type-utils@8.50.0(eslint@9.39.4(jiti@2.6.1))(typescript@5.4.4)': dependencies: '@typescript-eslint/types': 8.50.0 '@typescript-eslint/typescript-estree': 8.50.0(typescript@5.4.4) - '@typescript-eslint/utils': 8.50.0(eslint@9.39.3(jiti@2.6.1))(typescript@5.4.4) + '@typescript-eslint/utils': 8.50.0(eslint@9.39.4(jiti@2.6.1))(typescript@5.4.4) debug: 4.4.3 - eslint: 9.39.3(jiti@2.6.1) + eslint: 9.39.4(jiti@2.6.1) ts-api-utils: 2.1.0(typescript@5.4.4) typescript: 5.4.4 transitivePeerDependencies: @@ -8428,7 +8446,7 @@ snapshots: '@typescript-eslint/types@8.50.0': {} - '@typescript-eslint/types@8.57.1': {} + '@typescript-eslint/types@8.58.0': {} '@typescript-eslint/typescript-estree@8.50.0(typescript@5.4.4)': dependencies: @@ -8445,13 +8463,13 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.50.0(eslint@9.39.3(jiti@2.6.1))(typescript@5.4.4)': + '@typescript-eslint/utils@8.50.0(eslint@9.39.4(jiti@2.6.1))(typescript@5.4.4)': dependencies: - '@eslint-community/eslint-utils': 4.9.0(eslint@9.39.3(jiti@2.6.1)) + '@eslint-community/eslint-utils': 4.9.0(eslint@9.39.4(jiti@2.6.1)) '@typescript-eslint/scope-manager': 8.50.0 '@typescript-eslint/types': 8.50.0 '@typescript-eslint/typescript-estree': 8.50.0(typescript@5.4.4) - eslint: 9.39.3(jiti@2.6.1) + eslint: 9.39.4(jiti@2.6.1) typescript: 5.4.4 transitivePeerDependencies: - supports-color @@ -8864,6 +8882,8 @@ snapshots: assertion-error@2.0.1: {} + astring@1.9.0: {} + async@3.2.5: {} asynckit@0.4.0: {} @@ -9337,7 +9357,7 @@ snapshots: csstype@3.2.3: {} - dc-browser@1.0.3: {} + dc-browser@1.0.4: {} debug@2.6.9: dependencies: @@ -9530,9 +9550,9 @@ snapshots: escape-string-regexp@4.0.0: {} - eslint-plugin-node-import@1.0.5(eslint@9.39.3(jiti@2.6.1)): + eslint-plugin-node-import@1.0.5(eslint@9.39.4(jiti@2.6.1)): dependencies: - eslint: 9.39.3(jiti@2.6.1) + eslint: 9.39.4(jiti@2.6.1) eslint-scope@5.1.1: dependencies: @@ -9589,15 +9609,15 @@ snapshots: transitivePeerDependencies: - supports-color - eslint@9.39.3(jiti@2.6.1): + eslint@9.39.4(jiti@2.6.1): dependencies: - '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.3(jiti@2.6.1)) + '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.4(jiti@2.6.1)) '@eslint-community/regexpp': 4.12.2 '@eslint/config-array': 0.21.2 '@eslint/config-helpers': 0.4.2 '@eslint/core': 0.17.0 '@eslint/eslintrc': 3.3.5 - '@eslint/js': 9.39.3 + '@eslint/js': 9.39.4 '@eslint/plugin-kit': 0.4.1 '@humanfs/node': 0.16.7 '@humanwhocodes/module-importer': 1.0.1 @@ -9651,7 +9671,7 @@ snapshots: esrap@2.2.4: dependencies: '@jridgewell/sourcemap-codec': 1.5.5 - '@typescript-eslint/types': 8.57.1 + '@typescript-eslint/types': 8.58.0 esrecurse@4.3.0: dependencies: @@ -10816,6 +10836,8 @@ snapshots: merge2@1.4.1: {} + meriyah@6.1.4: {} + methods@1.1.2: {} micromatch@4.0.8: @@ -11564,6 +11586,8 @@ snapshots: secure-json-parse@2.7.0: {} + semifies@1.0.0: {} + semver@6.3.1: {} semver@7.6.2: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 93fe0f4ab..df5287654 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -7,6 +7,8 @@ packages: blockExoticSubdeps: true minimumReleaseAge: 4320 # 3 days (in minutes) +minimumReleaseAgeExclude: + - "@apm-js-collab/*" # instrumentation deps we need to pin closely trustPolicy: no-downgrade # Ignore the check for packages published more than 30 days ago (pnpm 10.27+) # Useful for older packages that pre-date provenance support