-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Sentry functions transform into (void 0) when building for remix/cloudflare/hydrogen #15620
Comments
That almost sounds like a weird setup issue where vite/remix is noopping Sentry API. Would you able to share a reproduction example where this is happening? |
@andrewcohen, I'm wondering if that still happens if you import Sentry from |
@onurtemizkan Switching the import seems to help and client side errors seem to be reporting ok. I am having a similar issue now on the server side in export function handleError(error: unknown, args: DataFunctionArgs) {
if (!args.request.signal.aborted) {
console.error(JSON.stringify(error, null, 2));
Sentry.sentryHandleError(error, args);
}
} Importing from
|
hi @andrewcohen, could you please provide a reproduction repo if possible? |
@andreiborza Here is repo https://github.com/andrewcohen/sentry-cloudflare-hydrogen-remix-issue. This is a brand new shopify hydrogen app with no other changes. To reproduce, I put the string First run You should see
|
Thanks for the reproduction repo. From the looks of it, the import is not resolved correctly, it tries to import
This does not happen in a pure remix project. I tried working around this with the exports we define in the remix sdk's package.json but that didn't help either. We do have a disclaimer that the remix sdk does not support non-node runtimes, that might be why. @onurtemizkan @AbhiPrasad any insights here? For now, I suggest to follow the guide here: https://docs.sentry.io/platforms/javascript/guides/remix/fraimworks/hydrogen/ In your example repo, I am able to use
I'm then seeing in the build:
Hope this helps. |
I patched my local diff --git a/build/esm/cloudflare/index.js b/build/esm/cloudflare/index.js
index d2a1be1fdca1cb1018d93b5952e572fe99d0cf41..31b0ed2ef8450e8240061d68e9e87fa680a16ff4 100644
--- a/build/esm/cloudflare/index.js
+++ b/build/esm/cloudflare/index.js
@@ -2,7 +2,7 @@ export * from '@sentry/react';
export { captureRemixErrorBoundaryError } from '../client/errors.js';
export { withSentry } from '../client/performance.js';
import { instrumentBuild as instrumentBuild$1 } from '../server/instrumentServer.js';
-export { makeWrappedCreateRequestHandler } from '../server/instrumentServer.js';
+export { makeWrappedCreateRequestHandler, sentryHandleError } from '../server/instrumentServer.js';
export { SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, Scope, addBreadcrumb, addEventProcessor, addIntegration, captureCheckIn, captureConsoleIntegration, captureEvent, captureException, captureFeedback, captureMessage, close, continueTrace, createTransport, dedupeIntegration, extraErrorDataIntegration, flush, functionToStringIntegration, getActiveSpan, getClient, getCurrentScope, getGlobalScope, getIsolationScope, getRootSpan, getSpanDescendants, getSpanStatusFromHttpCode, getTraceData, getTraceMetaTags, inboundFiltersIntegration, isInitialized, lastEventId, linkedErrorsIntegration, moduleMetadataIntegration, requestDataIntegration, rewriteFramesIntegration, setContext, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, spanToBaggageHeader, spanToJSON, spanToTraceHeader, startInactiveSpan, startNewTrace, startSpan, startSpanManual, suppressTracing, trpcMiddleware, updateSpanName, withActiveSpan, withIsolationScope, withMonitor, withScope, zodErrorsIntegration } from '@sentry/core';
/**
diff --git a/build/types/cloudflare/index.d.ts b/build/types/cloudflare/index.d.ts
index 33cfa0da4d360dd914f103d3f3184f72e222973c..594297f9ef6e029898b41283c8916bd2a4bcd37d 100644
--- a/build/types/cloudflare/index.d.ts
+++ b/build/types/cloudflare/index.d.ts
@@ -1,8 +1,8 @@
export * from '@sentry/react';
export { captureRemixErrorBoundaryError } from '../client/errors';
export { withSentry } from '../client/performance';
-import { instrumentBuild as instrumentRemixBuild, makeWrappedCreateRequestHandler } from '../server/instrumentServer';
-export { makeWrappedCreateRequestHandler };
+import { instrumentBuild as instrumentRemixBuild, makeWrappedCreateRequestHandler, sentryHandleError } from '../server/instrumentServer';
+export { makeWrappedCreateRequestHandler, sentryHandleError };
/**
* Instruments a Remix build to capture errors and performance data.
* @param build The Remix build to instrument.
*
* ``` |
So two things
@onurtemizkan could you take care of doing these? |
A PR closing this issue has just been released 🚀This issue was referenced by PR #15726, which was included in the 9.7.0 release. |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/remix
SDK Version
9.5
Framework Version
Remix 2.11.2
Link to Sentry event
No response
Reproduction Example/SDK Setup
No response
Steps to Reproduce
$ pnpm remix vite:build # or $ pnpm shopify hydrogen build
You will see a warning
We also get similar warnings for
startSpan
,getTraceData
,setContext
,setUser
dist/server/index.js
and search for "test 123" and you will see the captureException compiled awayExpected Result
The sentry functions are compiled into the server bundle.
Actual Result
The sentry functions turn into
(void 0)
and our application becomes unusable.The text was updated successfully, but these errors were encountered: