feat(cloudflare): Read wrangler config and resolve the Sentry options module#22421
Merged
Merged
Conversation
JPeer264
force-pushed
the
jp/cloudflare-auto-instrument-read-wrangler
branch
2 times, most recently
from
July 21, 2026 15:25
7fa0bdf to
f794a64
Compare
JPeer264
marked this pull request as ready for review
July 21, 2026 15:25
JPeer264
requested review from
andreiborza,
isaacs and
timfish
and removed request for
a team
July 21, 2026 15:25
timfish
reviewed
Jul 21, 2026
| try { | ||
| // `hideWarnings` keeps wrangler's config diagnostics (e.g. missing DO | ||
| // migrations) out of the Vite build output. | ||
| raw = unstable_readConfig({ config: configPath }, { hideWarnings: true }); |
Collaborator
There was a problem hiding this comment.
If you don't pass a config path, it says that wrangler will find the config. Would it be better to rely on the wrangler resolution?
Member
Author
There was a problem hiding this comment.
great suggestion, with that it gets way cleaner
Member
Author
There was a problem hiding this comment.
Ok I'll change that in a follow up PR. it gets too much of a mess with this stack otherwise
timfish
reviewed
Jul 21, 2026
| ]; | ||
|
|
||
| // Packages that cannot run in Node 18 | ||
| const SKIP_NODE_18_PACKAGES = ['@sentry/react-router']; |
Collaborator
There was a problem hiding this comment.
We just dropped Node v18 testing so this entre line might be redundant?
Member
Author
There was a problem hiding this comment.
True, I'll remove this. I think this can also be cleaned up entirely ?
I could do this in a separate PR
JPeer264
force-pushed
the
jp/cloudflare-auto-instrument-read-wrangler
branch
from
July 22, 2026 06:04
f794a64 to
e5d9096
Compare
timfish
approved these changes
Jul 22, 2026
JPeer264
force-pushed
the
jp/cloudflare-auto-instrument-read-wrangler
branch
3 times, most recently
from
July 22, 2026 12:54
2607d0b to
8864e2e
Compare
… module
Add the building blocks the auto-instrument Vite plugin will use, with no wiring
into a plugin yet:
- `wranglerConfig`: locate and parse `wrangler.{json,jsonc,toml}` via wrangler's
own `unstable_readConfig`, returning the worker entry (`main`) and the
configured Durable Object class names.
- `instrumentFile`: find a conventional `instrument.server.{ts,js,mjs,cjs}` next
to the entry and build the options import, falling back to an env-based
callback when absent.
- `defineCloudflareOptions`: identity helper that gives the options callback its
type in that module.
Adds `wrangler` as an optional peer dependency (used to read the config).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
JPeer264
force-pushed
the
jp/cloudflare-auto-instrument-read-wrangler
branch
from
July 22, 2026 13:12
8864e2e to
989fd3d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(replaces #22291)
part of #22066
Add the building blocks the auto-instrument Vite plugin will use, with no wiring into a plugin yet:
wranglerConfig: locate and parsewrangler.{json,jsonc,toml}via wrangler's ownunstable_readConfig, returning the worker entry (main) and the configured Durable Object class names.instrumentFile: find a conventionalinstrument.server.{ts,js,mjs,cjs}next to the entry and build the options import, falling back to an env-based callback when absent.defineCloudflareOptions: identity helper that gives the options callback its type in that module.Adds
wrangleras an optional peer dependency (used to read the config).The
instrument.server.*config can and should be written like the following:defineCloudflareOptionsis only adding typings forenvso it is easier it can also be used like the following:or
Future possibilities
For now there is a shared config for all instrumentations. In the future there would be the possibility to have different exports and map them to the actual bindings. E.g.: