-
Notifications
You must be signed in to change notification settings - Fork 762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Router-worker loss of sentry + metrics on error #7906
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 2c38e0c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
// Otherwise, we try to first fetch assets, falling back to user-Worker. | ||
if (env.CONFIG.has_user_worker) { | ||
return env.JAEGER.enterSpan("has_user_worker", async (span) => { | ||
if (await env.ASSET_WORKER.unstable_canFetch(request)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored here to reduce multiple nested if/else
"Fetch for user worker without having a user worker binding" | ||
); | ||
} | ||
if (!env.CONFIG.has_user_worker) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pulled out this error from the jaeger span so it would be caught in the try/catch block
return env.JAEGER.enterSpan("assets_only", async (span) => { | ||
// Otherwise, we either don't have a user worker, OR we have matching assets and should fetch from the assets binding | ||
analytics.setData({ dispatchtype: DISPATCH_TYPE.ASSETS }); | ||
return await env.JAEGER.enterSpan("dispatch_assets", async (span) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed all of these spans to be dispatch_assets
or dispatch_worker
. The tags inside are clear on why we dispatched assets or worker (based on hasWorker and assetsExist)
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12961811858/npm-package-wrangler-7906 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/7906/npm-package-wrangler-7906 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12961811858/npm-package-wrangler-7906 dev path/to/script.js Additional artifacts:cloudflare-workers-bindings-extension: wget https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12961811858/npm-package-cloudflare-workers-bindings-extension-7906 -O ./cloudflare-workers-bindings-extension.0.0.0-v8b5fdcaae.vsix && code --install-extension ./cloudflare-workers-bindings-extension.0.0.0-v8b5fdcaae.vsix create-cloudflare: npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12961811858/npm-package-create-cloudflare-7906 --no-auto-update @cloudflare/kv-asset-handler: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12961811858/npm-package-cloudflare-kv-asset-handler-7906 miniflare: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12961811858/npm-package-miniflare-7906 @cloudflare/pages-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12961811858/npm-package-cloudflare-pages-shared-7906 @cloudflare/unenv-preset: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12961811858/npm-package-cloudflare-unenv-preset-7906 @cloudflare/vite-plugin: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12961811858/npm-package-cloudflare-vite-plugin-7906 @cloudflare/vitest-pool-workers: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12961811858/npm-package-cloudflare-vitest-pool-workers-7906 @cloudflare/workers-editor-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12961811858/npm-package-cloudflare-workers-editor-shared-7906 @cloudflare/workers-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12961811858/npm-package-cloudflare-workers-shared-7906 @cloudflare/workflows-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12961811858/npm-package-cloudflare-workflows-shared-7906 Note that these links will no longer work once the GitHub Actions artifact expires.
Please ensure constraints are pinned, and |
7a71ec4
to
f25d3dd
Compare
f25d3dd
to
2c38e0c
Compare
return env.USER_WORKER.fetch(maybeSecondRequest); | ||
}).finally(() => { | ||
analytics.setData({ requestTime: performance.now() - startTimeMs }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to me that this would end up in a double write of metrics. Added a check in analytics.ts to prevent such an issue.
Fixes #[insert GH or internal issue link(s)].
Describe your change...