Repository navigation
Closed
Labels
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/astro
SDK Version
8.17.0
Framework Version
Astro 4.11.5
Link to Sentry event
No response
SDK Setup/Reproduction Example
https://stackblitz.com/edit/github-yligk2?file=astro.config.mjs
Steps to Reproduce
- Create a new blank Astro project.
- Install
@sentry/astroanddrizzle-orm. - Create a
src/middleware.tsfile. - Import any operator from
drizzle-orm:
import { or } from 'drizzle-orm';- Run the server and open the index page.
- Receive error:
MiddlewareCantBeLoadedbecausedrizzle-ormhas no export "or".
Expected Result
Pages should load as normal even if the middleware depends on drizzle-orm.
Actual Result
astro v4.11.5 ready in 415 ms
┃ Local http://localhost:4321/
┃ Network use --host to expose
24:59:05 watching for file changes...
24:59:15 [ERROR] [MiddlewareCantBeLoaded] An unknown error was thrown while loading your middleware.
Error reference:
https://docs.astro.build/en/reference/errors/middleware-cant-be-loaded/
Stack trace:
at /home/ibiyemi/projects/personal/rdvz-web/node_modules/astro/dist/core/middleware/loadMiddleware.js:8:24
[...] See full stack trace in the browser, or rerun with --verbose.
Caused by:
[vite] The requested module 'drizzle-orm' does not provide an export named 'or'
at analyzeImportedModDifference (file:///home/ibiyemi/projects/personal/rdvz-web/node_modules/vite/dist/node/chunks/dep-CzJTQ5q7.js:52533:15)
at async ssrImport (file:///home/ibiyemi/projects/personal/rdvz-web/node_modules/vite/dist/node/chunks/dep-CzJTQ5q7.js:53392:16)
at async instantiateModule (file:///home/ibiyemi/projects/personal/rdvz-web/node_modules/vite/dist/node/chunks/dep-CzJTQ5q7.js:53451:5)
Reacted by Tom MacWright and Kadeem Lewis
Metadata
Metadata
Labels
Projects
- StatusShow more project fieldsNo status
Activity
andreiborza commentedon Jul 15, 2024
Hello, thank you for writing in. I've tried reproducing this locally with an astro starter project and the steps outlined here but did not encounter the issue.
Could you please provide a sample repo or stackblitz?Taking a look at the provided stackblitz :)
andreiborza commentedon Jul 15, 2024
This looks to be some kind of issue with import in the middle and ESM. We are still investigating, but for now to get you unstuck you could create an empty
sentry.server.config.jsfile. You won't get any server-side instrumentation, just client-side but at least it should let you run your app.timfish commentedon Jul 15, 2024
I suspect this is the same issue as seen here:
nodejs/import-in-the-middle#139
I've got an open PR to fix this:
nodejs/import-in-the-middle#140
Lms24 commentedon Jul 15, 2024
@timfish lol I just opened another issue in nodejs/import-in-the-middle#141 b/c I missed the connection to nodejs/import-in-the-middle#139 😅
53 remaining items
laptou commentedon Aug 7, 2024
@RIP21 I don't understand how you solved the issue. Can you give an example please? I'm not using a preload because I don't have any special hooks, but I would love to use one if it will let me add Sentry back into my application.
RIP21 commentedon Aug 7, 2024
@laptou inused include instead of exclude, including all the dependencies (excluding dev dependencies) I use except Drizzle-orm and it worked. Just doing exclude on Drizzle-orm didn't work out for me.
@timfish @mydea FYI, maybe it's also a problem, but I hope underlying issue will be solved so these include/exclude won't be needed (BTW which issues to subscribe to to track that?)
mydea commentedon Aug 8, 2024
We are working on #13139, and will eventually look at using this by default, which will allow you to skip wrapping anything that we are not explicitly instrumenting, without having to define packages manually!
timfish commentedon Sep 9, 2024
v8.29.0 of the Node SDK adds the new
onlyIncludeInstrumentedModulesoption toregisterEsmLoaderHooks.When set to
true,import-in-the-middlewill only wrap ESM modules that are specifically instrumented by OpenTelemetry plugins. This is useful to avoid issues whereimport-in-the-middleis not compatible with some of your dependencies.This feature will only work if you
Sentry.init()the SDK before the instrumented modules are loaded. This can be achieved via the Node--registerand--importCLI flags or by loading your app code via asyncimport()after callingSentry.init().Please let me know if this helps solve the
import-in-the-middleincompatibility issues you are experiencing!AbhiPrasad commentedon Nov 1, 2024
Closing this for clean-up. If this issue still applies, please re-open. Thanks!