Skip to content
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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

WillTaylorDev
Copy link
Contributor

@WillTaylorDev WillTaylorDev commented Jan 25, 2025

Fixes #[insert GH or internal issue link(s)].

Describe your change...


  • Tests
    • TODO (before merge)
    • Tests included
    • Tests not necessary because:
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • Not required because:
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Documentation not necessary because:

Copy link

changeset-bot bot commented Jan 25, 2025

🦋 Changeset detected

Latest commit: 2c38e0c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cloudflare/workers-shared Minor

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)) {
Copy link
Contributor Author

@WillTaylorDev WillTaylorDev Jan 25, 2025

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) {
Copy link
Contributor Author

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) => {
Copy link
Contributor Author

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)

Copy link
Contributor

github-actions bot commented Jan 25, 2025

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 with this latest build directly:

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.


wrangler@3.105.1 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20250124.0
workerd 1.20250124.0 1.20250124.0
workerd --version 1.20250124.0 2025-01-24

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

@WillTaylorDev WillTaylorDev force-pushed the willtaylor/catch-errors-jaeger-router-worker branch from 7a71ec4 to f25d3dd Compare January 25, 2025 04:22
@WillTaylorDev WillTaylorDev force-pushed the willtaylor/catch-errors-jaeger-router-worker branch from f25d3dd to 2c38e0c Compare January 25, 2025 04:27
return env.USER_WORKER.fetch(maybeSecondRequest);
}).finally(() => {
analytics.setData({ requestTime: performance.now() - startTimeMs });
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Untriaged
Development

Successfully merging this pull request may close these issues.

1 participant