Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,14 @@ jobs:
label: cloudflare-workers
shardIndex: 1
shardTotal: 1
- project: cloudflare-sentry-app
label: cloudflare-sentry-app
shardIndex: 1
shardTotal: 1
- project: cloudflare-sentry-pages
label: cloudflare-sentry-pages
shardIndex: 1
shardTotal: 1
- project: cloudflare-dev
label: cloudflare-dev
shardIndex: 1
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@changesets/cli": "2.31.0",
"@mswjs/interceptors": "catalog:",
"@playwright/test": "catalog:",
"@sentry/nextjs": "catalog:",
"@types/node": "catalog:",
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
Expand Down
25 changes: 25 additions & 0 deletions packages/vinext/src/shims/request-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,31 @@ export type ExecutionContextLike = {
// ---------------------------------------------------------------------------

const _als = getOrCreateAls<ExecutionContextLike | null>("vinext.requestContext.als");
const OPEN_NEXT_CLOUDFLARE_CONTEXT_SYMBOL = Symbol.for("__cloudflare-context__");
let openNextCloudflareContextFallback: unknown;

function installOpenNextCloudflareContextBridge(): void {
const descriptor = Object.getOwnPropertyDescriptor(
globalThis,
OPEN_NEXT_CLOUDFLARE_CONTEXT_SYMBOL,
);
if (descriptor && !descriptor.configurable) return;
openNextCloudflareContextFallback =
descriptor && "value" in descriptor ? descriptor.value : descriptor?.get?.call(globalThis);

Object.defineProperty(globalThis, OPEN_NEXT_CLOUDFLARE_CONTEXT_SYMBOL, {
configurable: true,
get() {
const ctx = getRequestExecutionContext();
return ctx ? { ctx } : openNextCloudflareContextFallback;
},
set(value: unknown) {
openNextCloudflareContextFallback = value;
},
});
}

installOpenNextCloudflareContextBridge();

// ---------------------------------------------------------------------------
// Public API
Expand Down
26 changes: 26 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,32 @@ const projectServers = {
timeout: 60_000,
},
},
"cloudflare-sentry-app": {
testDir: "./tests/e2e",
testMatch: ["**/cloudflare-sentry-app/**/*.spec.ts"],
use: { baseURL: "http://localhost:4193" },
server: {
command:
"NEXT_PUBLIC_VINEXT_TEST_SENTRY_DSN=http://public@localhost:4193/1 npx vp build && npx wrangler dev --port 4193",
cwd: "./tests/fixtures/cf-sentry-app",
port: 4193,
reuseExistingServer: !process.env.CI,
timeout: 60_000,
},
},
"cloudflare-sentry-pages": {
testDir: "./tests/e2e",
testMatch: ["**/cloudflare-sentry-pages/**/*.spec.ts"],
use: { baseURL: "http://localhost:4194" },
server: {
command:
"NEXT_PUBLIC_VINEXT_TEST_SENTRY_DSN=http://public@localhost:4194/1 npx vp build && npx wrangler dev --port 4194",
cwd: "./tests/fixtures/cf-sentry-pages",
port: 4194,
reuseExistingServer: !process.env.CI,
timeout: 60_000,
},
},
"cloudflare-dev": {
testDir: "./tests/e2e",
testMatch: [
Expand Down
Loading
Loading