Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 1 addition & 3 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 Down
3 changes: 1 addition & 2 deletions 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,
failOnWarn: false
Copy link
Member

@mydea mydea Dec 12, 2024

Choose a reason for hiding this comment

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

l: should we just remove this, and use the default?

Suggested change
failOnWarn: false

Copy link
Member Author

Choose a reason for hiding this comment

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

I kept it because I think it's not a good idea to fail on warnings

Copy link
Member Author

Choose a reason for hiding this comment

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

...and there is a warning about the types
Potential missing package.json files: build/types/index.types.d.ts

As far as I know there is no issue with that and this could be a warning cause by the 2-step build.

});
9 changes: 6 additions & 3 deletions packages/nuxt/rollup.npm.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ 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) */

Copy link
Member

Choose a reason for hiding this comment

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

let's just remove all of this instead of commenting it out!

// 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'],
Expand All @@ -31,4 +33,5 @@ export default [
},
}),
),
*/
];
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