Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

@sentry/cloudflare/vite: Auto-instrumentation skips the Worker when wrangler `main` is a package specifier

オープン
#24,522 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
58/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript, vite

調査の方向性

Start with packages/cloudflare/src/vite/wranglerConfig.ts, autoInstrument.ts, and instrumentFile.ts, then inspect the existing Cloudflare Vite test fixtures. Trace how Wrangler's main value is resolved and compared with transformed module IDs. Done means package-specifier entries are instrumented, node_modules entries find the project instrument file, unmatched entries produce a warning, and a package-specifier fixture passes.

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

説明

Cloudflare Workers Feature
Description

sentryCloudflareVitePlugin() does not wrap the Worker when main in the Wrangler config is a package specifier and not a file path. The build succeeds, but the bundle contains no Sentry code, and the plugin logs no warning.

@cloudflare/vite-plugin supports this config, and vinext generates it by default with vinext init --platform=cloudflare:

// wrangler.jsonc
{
  "main": "vinext/server/fetch-handler",
  // ...
}
// vite.config.ts
export default defineConfig({
  plugins: [
    vinext(),
    cloudflare({ viteEnvironment: { name: "rsc", childEnvironments: ["ssr"] } }),
    sentryCloudflareVitePlugin(),
  ],
});

Tested with @sentry/cloudflare@11.0.0-rc.0, @cloudflare/vite-plugin@1.56.0, wrangler@4.135.0, vinext@1.0.0-beta.10 and Vite 8.3.

Cause

resolveWranglerConfig() calls unstable_readConfig() without preserveOriginalMain (wranglerConfig.ts#L70). Wrangler then resolves every main as a path relative to the config file:

main: "vinext/server/fetch-handler"
-> <project>/vinext/server/fetch-handler   (file does not exist)

autoInstrument.ts compares this path with the module IDs in transform (L75), so no module matches. resolveInstrumentFile() also looks for instrument.server.* in the directory of this path (instrumentFile.ts#L23), and a package entry has no such file.

@cloudflare/vite-plugin handles the same value differently:

  1. It reads the config with unstable_readConfig(..., { preserveOriginalMain: true }).
  2. maybeResolveMain() makes main absolute only when it ends with a JS or TS extension.
  3. It resolves the entry with Vite: await this.resolve(workerConfig.main).
Workaround

Add a local entry that re-exports the package entry, and set main to it. Put instrument.server.ts in the same directory:

// worker/index.ts
import handler from "vinext/server/fetch-handler";

export default handler;
{ "main": "./worker/index.ts" }
Proposed fix
  • Read the config with preserveOriginalMain: true, and keep a package specifier unchanged.
  • Resolve main with this.resolve() (for example in buildStart, or lazily in transform), and compare the resolved module ID.
  • When the resolved entry is in node_modules, look for instrument.server.* in the Wrangler config directory (the Vite root) and not next to the entry.
  • Log a warning when main does not resolve to a module that the plugin transforms, so the failure is not silent.
  • Add a test fixture where main is a package specifier.
主要言語
TypeScript
スター
8.7k
フォーク
1.9k
平均マージ
1日 16時間
マージ済み PR(30日)
576

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

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

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

getsentry/sentry-javascript のほかの issue

getsentry/sentry-javascript の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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