Skip to content

fix(cloud): forward /api/sentry-tunnel to Sentry ingest#273

Closed
RhysSullivan wants to merge 3 commits intors/secrets-parallel-fanoutfrom
rs/sentry-tunnel
Closed

fix(cloud): forward /api/sentry-tunnel to Sentry ingest#273
RhysSullivan wants to merge 3 commits intors/secrets-parallel-fanoutfrom
rs/sentry-tunnel

Conversation

@RhysSullivan
Copy link
Copy Markdown
Owner

routes/__root.tsx configures the browser Sentry SDK with
tunnel: '/api/sentry-tunnel' but nothing served that path — every
error report came back RouteNotFound.

Add a request middleware (before the /api/* router) that intercepts
POST /api/sentry-tunnel, parses the envelope's first-line header to
recover the DSN, and forwards the raw body to
https:///api//envelope/. The envelope's DSN is
validated against env.SENTRY_DSN (host + pathname) to keep this from
being an open relay for the Sentry ingest. Missing DSN → 204; bad
envelope → 400.

…nked bulk INSERT

Drizzle adapter had no native createMany — the factory's fallback looped
through per-row inserts. For a Cloudflare-scale OpenAPI spec (~2700 ops)
addSpec devolved to ~10 000 sequential INSERTs through Hyperdrive inside
a single transaction, blowing both the Worker CPU / memory budget and
any reasonable wall-clock.

Changes:

- storage-core/adapter.ts: CustomAdapter.createMany is now required
  (no ?). Backends must implement a real bulk insert; there is no
  silent per-row fallback to mask prod regressions.

- storage-core/factory.ts: drop the loop fallback entirely. createMany
  delegates to inner.createMany, applying per-row input/output
  transforms so JSON / dates / booleans serialize the same as single
  create().

- storage-core/testing/memory.ts: native createMany that just pushes
  rows into the in-memory table.

- storage-drizzle/adapter.ts: real db.insert(table).values(rows).returning()
  in chunks of 500. One statement per chunk (so ~6 round-trips for 2700
  ops, not 2700). Chunking also keeps any single statement under ~2MB
  — a single giant INSERT would choke Hyperdrive ingress and the WASM
  PGlite used in tests. Fails loudly on mysql (no RETURNING).
Several per-request hot paths iterated secret providers with sequential
yield*, turning a fan-out into N round-trips. Fix by switching to
Effect.all(..., { concurrency: 'unbounded' }).

- executor.ts secretsGet fallback: when the core routing-table misses,
  ask every enumerating provider in parallel; first non-null in
  registration order wins. Providers that throw are still treated as
  'don't have it'.

- executor.ts secretsRemove: delete across every writable provider in
  parallel. Providers don't coordinate on ownership — each gets asked,
  and most calls are no-ops.

- executor.ts secretsList: provider.list() runs in parallel, then the
  results are merged in registration order so 'first provider wins'
  precedence remains deterministic.

- openapi/invoke.ts + graphql/invoke.ts resolveHeaders: resolve
  secret-backed headers in parallel. OpenAPI fails the invocation on
  any missing secret (unchanged semantics); GraphQL drops the header
  silently on failure (unchanged semantics).

N is small (3-5 providers, 1-5 headers) so parallelism is unbounded;
no Effect.all concurrency cap needed.
routes/__root.tsx configures the browser Sentry SDK with
tunnel: '/api/sentry-tunnel' but nothing served that path — every
error report came back RouteNotFound.

Add a request middleware (before the /api/* router) that intercepts
POST /api/sentry-tunnel, parses the envelope's first-line header to
recover the DSN, and forwards the raw body to
https://<dsn host>/api/<project>/envelope/. The envelope's DSN is
validated against env.SENTRY_DSN (host + pathname) to keep this from
being an open relay for the Sentry ingest. Missing DSN → 204; bad
envelope → 400.
Copy link
Copy Markdown
Owner Author

RhysSullivan commented Apr 17, 2026

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 17, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud 94ce0db Apr 17 2026, 07:00 PM

@RhysSullivan RhysSullivan marked this pull request as ready for review April 17, 2026 19:01
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 17, 2026

Open in StackBlitz

@executor/sdk

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/sdk@273

@executor/plugin-file-secrets

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-file-secrets@273

@executor/plugin-google-discovery

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-google-discovery@273

@executor/plugin-graphql

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-graphql@273

@executor/plugin-keychain

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-keychain@273

@executor/plugin-mcp

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-mcp@273

@executor/plugin-oauth2

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-oauth2@273

@executor/plugin-onepassword

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-onepassword@273

@executor/plugin-openapi

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-openapi@273

@executor/plugin-workos-vault

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-workos-vault@273

executor

npm i https://pkg.pr.new/RhysSullivan/executor@273

commit: 94ce0db

@RhysSullivan RhysSullivan force-pushed the rs/secrets-parallel-fanout branch from d556b11 to 165e770 Compare April 17, 2026 19:03
@RhysSullivan RhysSullivan deleted the branch rs/secrets-parallel-fanout April 17, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant