getsentry / getsentry/sentry-javascript

Nuxt dev server loads DB drivers before Sentry.init()

オープン
#23,876 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
Bug javascript Node.js
主要言語
TypeScript
スター
8.7k
フォーク
1.8k
平均マージ
1日 17時間
マージ済み PR(30日)
515

説明

In `nuxt dev`, `ioredis` and `mysql` never get DB spans. The SDK starts fine and `http.server` transactions arrive, but the DB spans are missing.

It's a load-order problem. Nitro generates `.nuxt/dev/sentry.server.config.mjs`, the file `nuxt dev` passes to `--import`, as a list of imports for the whole dev server:

```js
import './index.mjs'; // the whole Nitro dev server
// … a few more imports …
import '…/node_modules/ioredis/built/index.js';
import '…/node_modules/mysql/index.js';
// … more imports, then Sentry.init() somewhere inside
```

ESM runs all imports before any code, so both drivers are loaded by the time `Sentry.init()` runs, and the runtime hook can't instrument a module that loaded first. A probe on `Module.prototype._compile` confirms it: when `ioredis` compiles, `globalThis.__SENTRY_ORCHESTRION__` doesn't exist yet.

This isn't only about orchestrion. Anything that needs `Sentry.init()` to run before a dependency loads is unreliable in `nuxt dev`.

**Repro:** in `dev-packages/e2e-tests/test-applications/nuxt-4`, run `bash ./nuxt-start-dev-server.bash && TEST_ENV=development playwright test db-drivers`. Both tests time out; the dev pass is filtered to `environment` today for this reason.

Found while working on JS-3233 (#22857). Blocks the nuxt-4 dev DB tests (#23836).

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Reproduce the failure from dev-packages/e2e-tests/test-applications/nuxt-4 with nuxt-start-dev-server.bash and the db-drivers Playwright test. Inspect the generated .nuxt/dev/sentry.server.config.mjs and the Nuxt dev entry point to trace import timing; done means the DB-driver tests pass in development without the environment filter.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
mysql, nodejs, nuxt, playwright, typescript
領域
backend, observability-sre, testing-qa
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
55/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。