Skip to content

Commit

Permalink
refactor: update worker-utils and related Toucan dependencies for com…
Browse files Browse the repository at this point in the history
…patibility

- Updated worker-utils package to the latest version
- Updated related Toucan dependencies to ensure compatibility with the newer worker-utils version
  • Loading branch information
BravoNatalie committed Nov 14, 2024
1 parent 11aec0f commit 760d97b
Show file tree
Hide file tree
Showing 3 changed files with 5,434 additions and 6,161 deletions.
8 changes: 4 additions & 4 deletions packages/edge-gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"mock:cf-ipfs.com": "smoke -p 9083 test/mocks/cf-ipfs.com"
},
"dependencies": {
"@web3-storage/worker-utils": "^0.3.0-dev",
"@web3-storage/worker-utils": "^0.6.0-dev",
"ipfs-core-utils": "^0.15.0",
"ipfs-gateway-race": "link:../ipfs-gateway-race",
"itty-router": "^2.4.5",
Expand All @@ -28,12 +28,12 @@
"p-retry": "^5.0.0",
"p-settle": "^5.0.0",
"p-some": "^5.0.0",
"toucan-js": "^2.5.0",
"toucan-js": "^3.4.0",
"uint8arrays": "^3.0.0"
},
"devDependencies": {
"@cloudflare/workers-types": "^3.7.1",
"@sentry/cli": "^1.71.0",
"@sentry/cli": "^2.7.0",
"@types/git-rev-sync": "^2.0.0",
"@web-std/fetch": "^4.0.0",
"ava": "^3.15.0",
Expand Down Expand Up @@ -65,4 +65,4 @@
},
"author": "Vasco Santos <[email protected]>",
"license": "Apache-2.0 OR MIT"
}
}
32 changes: 20 additions & 12 deletions packages/edge-gateway/src/env.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* global BRANCH, VERSION, COMMITHASH, SENTRY_RELEASE */
import Toucan from 'toucan-js'
import { Toucan, RewriteFrames } from 'toucan-js'

import { Logging } from '@web3-storage/worker-utils/loki'
import { createGatewayRacer } from 'ipfs-gateway-race'

import pkg from '../package.json'
import {
DEFAULT_RACE_L1_GATEWAYS,
DEFAULT_RACE_L2_GATEWAYS,
Expand Down Expand Up @@ -69,11 +68,22 @@ export function envAll (request, env, ctx) {
worker: 'edge-gateway',
env: env.ENV,
sentry: env.sentry,
/**
*
* @param {import('@web3-storage/worker-utils/loki').Log} log
* @returns object
*/
filterFields: (log) => {
const { metadata } = log
const { cf, ...filteredFields } = metadata
const { request, ...restMetadata } = metadata

return { ...log, metadata: filteredFields }
// Destructure to omit the `cf` field from `request`
const { cf, ...filteredRequest } = request

return {
...log,
metadata: { ...restMetadata, request: filteredRequest }
}
}
})
env.log.time('request')
Expand Down Expand Up @@ -117,15 +127,13 @@ function getSentry (request, env, ctx) {
request,
dsn: env.SENTRY_DSN,
context: ctx,
allowedHeaders: ['user-agent'],
allowedSearchParams: /(.*)/,
requestDataOptions: {
allowedHeaders: ['user-agent'],
allowedSearchParams: /(.*)/
},
integrations: [new RewriteFrames({ root: '/' })],
debug: false,
environment: env.ENV || 'dev',
rewriteFrames: {
// sourcemaps only work if stack filepath are absolute like `/worker.js`
root: '/'
},
release: env.SENTRY_RELEASE,
pkg
release: env.SENTRY_RELEASE
})
}
Loading

0 comments on commit 760d97b

Please sign in to comment.