Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions packages/nitro-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/nitro-utils",
"author": "Sentry",
"license": "MIT",
"private": true,
"engines": {
"node": ">=16.20"
},
Expand Down Expand Up @@ -35,9 +36,6 @@
]
}
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"@sentry/core": "8.44.0"
},
Expand All @@ -55,7 +53,6 @@
"build:dev:watch": "run-p build:transpile:watch build:types:watch",
"build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch",
"build:types:watch": "tsc -p tsconfig.types.json --watch",
"build:tarball": "npm pack",
"clean": "rimraf build coverage sentry-internal-nitro-utils-*.tgz",
"fix": "eslint . --format stylish --fix",
"lint": "eslint . --format stylish",
Expand Down
1 change: 0 additions & 1 deletion packages/nuxt/build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ import { defineBuildConfig } from 'unbuild';

// Build Config for the Nuxt Module Builder: https://github.com/nuxt/module-builder
export default defineBuildConfig({
// The devDependency "@sentry-internal/nitro-utils" triggers "Inlined implicit external", but it's not external
failOnWarn: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
failOnWarn: false,

});
1 change: 0 additions & 1 deletion packages/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
},
"devDependencies": {
"@nuxt/module-builder": "^0.8.4",
"@sentry-internal/nitro-utils": "8.44.0",
"nuxt": "^3.13.2"
},
"scripts": {
Expand Down
16 changes: 0 additions & 16 deletions packages/nuxt/rollup.npm.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,4 @@ export default [
},
}),
),
/* The Nuxt module plugins are also built with the @nuxt/module-builder.
This rollup setup is still left here for an easier switch between the setups while
manually testing different built outputs (module-builder vs. rollup only) */
...makeNPMConfigVariants(
makeBaseNPMConfig({
entrypoints: ['src/runtime/plugins/sentry.client.ts', 'src/runtime/plugins/sentry.server.ts'],

packageSpecificConfig: {
external: ['nuxt/app', 'nitropack/runtime', 'h3'],
output: {
// Preserve the original file structure (i.e., so that everything is still relative to `src`)
entryFileNames: 'runtime/[name].js',
},
},
}),
),
];
38 changes: 35 additions & 3 deletions packages/nuxt/src/runtime/plugins/sentry.server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { patchEventHandler } from '@sentry-internal/nitro-utils';
import { GLOBAL_OBJ, flush, getClient, logger, vercelWaitUntil } from '@sentry/core';
import {
GLOBAL_OBJ,
flush,
getClient,
getDefaultIsolationScope,
getIsolationScope,
logger,
vercelWaitUntil,
withIsolationScope,
} from '@sentry/core';
import * as Sentry from '@sentry/node';
import { H3Error } from 'h3';
import { type EventHandler, H3Error } from 'h3';
import { defineNitroPlugin } from 'nitropack/runtime';
import type { NuxtRenderHTMLContext } from 'nuxt/app';
import { addSentryTracingMetaTags, extractErrorContext } from '../utils';
Expand Down Expand Up @@ -66,3 +74,27 @@ async function flushWithTimeout(): Promise<void> {
isDebug && logger.log('Error while flushing events:\n', e);
}
}

// copied from '@sentry-internal/nitro-utils' - the nuxt-module-builder does not inline devDependencies
function patchEventHandler(handler: EventHandler): EventHandler {
return new Proxy(handler, {
async apply(handlerTarget, handlerThisArg, handlerArgs: Parameters<EventHandler>) {
const isolationScope = getIsolationScope();
const newIsolationScope = isolationScope === getDefaultIsolationScope() ? isolationScope.clone() : isolationScope;

logger.log(
`Patched h3 event handler. ${
isolationScope === newIsolationScope ? 'Using existing' : 'Created new'
} isolation scope.`,
);

return withIsolationScope(newIsolationScope, async () => {
try {
return await handlerTarget.apply(handlerThisArg, handlerArgs);
} finally {
await flushIfServerless();
}
});
},
});
}
Loading