GeezerVison is showing github.com — fix(server-utils): Fix orchestrion source maps of instrumented modules by JPeer264 · Pull Request #25772 · getsentry/sentry-javascript
fix(server-utils): Fix orchestrion source maps of instrumented modules
#25772
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
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from all commits
Commits
File filter
Filter by extension
.json
(2)
.ts
(3)
.yaml
(1)
All 3 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -49,8 +49,8 @@
"@sentry/server-utils": "11.10.0"
},
"devDependencies": {
"@apm-js-collab/code-transformer": "^0.18.1 ",
"@apm-js-collab/tracing-hooks": "^0.13.3 ",
"@apm-js-collab/code-transformer": "^0.19.0 ",
"@apm-js-collab/tracing-hooks": "^0.14.0 ",
"@sentry-internal/rollup-utils": "11.10.0",
"@types/node": "^20.19.0",
"@vercel/nft": "^1.11.0",
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -101,7 +101,7 @@
"@sentry/core": "11.10.0"
},
"devDependencies": {
"@apm-js-collab/code-transformer-bundler-plugins": "^0.7.4 ",
"@apm-js-collab/code-transformer-bundler-plugins": "^0.7.5 ",
"@neondatabase/serverless": "1.2.0",
"@sentry-internal/rollup-utils": "11.10.0",
"@types/node": "^20.19.0",
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -16,8 +16,11 @@ import { externalEntryMatchesModule, externalizedModulesWarning, orchestrionTran
// Explicitly annotated with the vendored types so the emitted declaration doesn't reference
// `@apm-js-collab/code-transformer-bundler-plugins` — a bundled devDependency consumers don't have.
export const serializeInstrumentations: (configs: AnyInstrumentationConfig[]) => SerializableInstrumentationConfig[] =
serializeInstrumentationsImpl;
// Upstream also allows a function in `transform`. The vendored configs only allow a string there,
// and the serializer copies `transform` unchanged, so its output only contains strings too.
export const serializeInstrumentations = serializeInstrumentationsImpl as (
configs: AnyInstrumentationConfig[],
) => SerializableInstrumentationConfig[];
export type { SerializableInstrumentationConfig } from '../apmTypes';
export { getOrchestrionLoaderPath, resolveOrchestrionRuntimeRequest };
Expand Down
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
import type { InstrumentationConfig } from '@apm-js-collab/code-transformer-bundler-plugins/core ';
import type { InstrumentationConfig } from '../../src/orchestrion/apmTypes ';
import { describe, expect, it } from 'vitest';
import {
getInstrumentedModuleNames,
Expand Down
Original file line number
Diff line number
Diff line change
@@ -0,0 +1,59 @@
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { build, type Plugin, type Rollup } from 'vite';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
import type { InstrumentationConfig } from '../../src/orchestrion/apmTypes';
import { sentryOrchestrionPlugin as sentryOrchestrionRollupPlugin } from '../../src/orchestrion/bundler/rollup';
import { sentryOrchestrionPlugin as sentryOrchestrionVitePlugin } from '../../src/orchestrion/bundler/vite';
const instrumentations: InstrumentationConfig[] = [
{
channelName: 'query',
module: { name: 'fake-db', versionRange: '>=1.0.0', filePath: 'index.js' },
functionQuery: { expressionName: 'query', kind: 'Sync' },
},
];
describe('orchestrion bundler plugins source maps', () => {
let root: string;
beforeAll(() => {
root = mkdtempSync(join(tmpdir(), 'orchestrion-sourcemap-'));
const packageDir = join(root, 'node_modules', 'fake-db');
mkdirSync(packageDir, { recursive: true });
writeFileSync(join(packageDir, 'package.json'), JSON.stringify({ name: 'fake-db', version: '1.0.0' }));
writeFileSync(join(packageDir, 'index.js'), 'exports.query = function query(sql) {\n return sql;\n};\n');
writeFileSync(
join(root, 'server.js'),
"import { query } from 'fake-db';\nexport const run = () => query('SELECT 1');\n",
);
});
afterAll(() => rmSync(root, { recursive: true, force: true }));
// https://github.com/getsentry/sentry-javascript/issues/25329
it.each([
['vite', () => sentryOrchestrionVitePlugin({ instrumentations })],
['rollup', () => sentryOrchestrionRollupPlugin({ instrumentations }) as Plugin],
])('maps the transformed module only to its file in node_modules (%s plugin)', async (_name, createPlugin) => {
const output = (await build({
root,
configFile: false,
logLevel: 'silent',
plugins: [createPlugin()],
ssr: { noExternal: ['fake-db'] },
build: {
ssr: 'server.js',
sourcemap: true,
write: false,
rollupOptions: { external: ['@sentry/server-utils'] },
},
})) as Rollup.RollupOutput;
const chunk = output.output[0];
expect(chunk.code).toContain('orchestrion:fake-db:query');
expect(chunk.map?.sources).toEqual(['../node_modules/fake-db/index.js', '../server.js']);
});
});
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.