Skip to content

Commit 8c4e49e

Browse files
authored
Merge branch 'develop' into fix/nitro-windows-plugin-path
2 parents 82a279c + 95c1146 commit 8c4e49e

837 files changed

Lines changed: 6627 additions & 4434 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.agents/skills/write-tests/SKILL.md‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,16 +307,31 @@ it.each([
307307
### Test isolation
308308

309309
Tests must never depend on execution order or share mutable state. For this codebase, many tests
310-
need to reset global Sentry state:
310+
need to reset global Sentry state. Use whatever reset the existing tests in your package use (many
311+
packages have a `resetSdk()` or `cleanupOtel()` helper). Otherwise, pick one:
311312

312313
```typescript
313-
beforeEach(() => {
314-
clearGlobalScope();
315-
getCurrentScope().clear();
316-
getIsolationScope().clear();
317-
});
314+
// Unbind the client. Cheap, and enough for most tests that call `init()`.
315+
getCurrentScope().setClient(undefined);
316+
317+
// Reset the global, isolation, and current scopes, and the client bound to them.
318+
// `setupOnce` still does not run again, because installed integrations are tracked
319+
// outside the carrier.
320+
getMainCarrier().__SENTRY__ = undefined;
321+
322+
// Close and unbind the client. Also flushes, so it is slower.
323+
await Sentry.close();
318324
```
319325

326+
**Reset the client in every test that calls `init()`.** A second `init()` while a client is bound
327+
prints a "`Sentry.init()` was called more than once" warning. After the next major version, it will
328+
return the bound client instead of a new one, so a test without a reset gets the previous test's
329+
client and options. See `docs/repeated-init.md`.
330+
331+
To assert on that warning (or any `consoleSandbox` output), stub `originalConsoleMethods.warn` from
332+
`@sentry/core`. `consoleSandbox` calls the stored original method, so a spy on `console.warn` misses
333+
it once the console integration is set up.
334+
320335
### Grouping
321336

322337
1-2 levels of `describe` is usually enough. Deeper nesting makes tests harder to find and read.
@@ -526,6 +541,7 @@ Before you're done, verify each test against these criteria:
526541
- [ ] Description reads as a behavior specification (no "should", no "works correctly")
527542
- [ ] No dependency on other tests' execution or state
528543
- [ ] Mocks and spies are restored (via `beforeEach`)
544+
- [ ] Tests that call `init()` reset the bound client between tests
529545
- [ ] Edge cases covered: empty inputs, boundaries, error paths, null/undefined
530546
- [ ] Realistic test data (not `"foo"`, `"test"`, `123`)
531547
- [ ] No try/catch for error testing — `toThrow` / `rejects.toThrow` only

‎.cursor/BUGBOT.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Keep reviews high-signal. Prefer actionable, high-confidence findings over specu
7676
- Flag usage of the following APIs: `getCurrentScope()`, `getIsolationScope()`, `getClient()` if they are avoidable. Flag it with severity Low and acknowledge from the start that this is more a "is this necessary" check, rather than a rule violation.
7777
- Reason for flagging: Usage of these APIs is problematic for multi-client setups where either there is no "current" client/scope, or the wrong client might be used. Calling these APIs would create a current scope, thereby misleading any future calls to these APIs.
7878
- What to do instead: Use an existing reference to the scope or client. For example, this is possible in most `Integration` hooks.
79+
- Flag hard-coded attribute names and span ops (e.g. `'sentry.origin'`, `'sentry.op'`, `'http.request.method'`, `'db.system.name'`) when `@sentry/conventions` exports a constant for them. Use the constant from `@sentry/conventions/attributes` (e.g. `SENTRY_ORIGIN`, `SENTRY_OP`) or `@sentry/conventions/op` instead. Do not flag values that have no constant in `@sentry/conventions`.
7980
- Flag unnecessary `span.setAttribute(s)` calls: If data is already available at span start, it must be set via the `attributes` option of `startSpan`, `startSpanManual`, `startInactiveSpan` or `startIdleSpan` calls. This ensures that as much context as possible is available when `tracesSampler` or `ignoreSpans` SDK options are applied. If a `span.setAttribute(s)` call happens at a later time than right after span start and the attribute value can only be computed at that time, do not flag it.
8081

8182
### Code quality
@@ -92,6 +93,7 @@ Keep reviews high-signal. Prefer actionable, high-confidence findings over specu
9293
- Flag usage of `expect.objectContaining` and other relaxed assertions, when a test expects something NOT to be included in a payload but there's no respective assertion.
9394
- Flag usage of conditionals in one test and recommend splitting up the test for the different paths.
9495
- Flag usage of loops testing multiple scenarios in one test and recommend using `(it)|(test).each` instead.
96+
- Apply the `@sentry/conventions` constants rule from above to test files too. Test assertions on span attributes and ops must use the constants, not string literals.
9597
- Flag tests that are likely to introduce flakes. In our case this usually means we wait for some telemetry requests sent from an SDK. Patterns to look out for:
9698
- Only waiting for a request, after an action is performed. Instead, start waiting, perform action, await request promise.
9799
- Race conditions when waiting on multiple requests. Ensure that waiting checks are unique enough and don't depend on a hard order when there's a chance that telemetry can be sent in arbitrary order.

‎.github/workflows/build.yml‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,8 @@ jobs:
10381038
REACT_APP_E2E_TEST_DSN: 'https://username@domain/123'
10391039
E2E_TEST_SENTRY_ORG_SLUG: 'sentry-javascript-sdks'
10401040
E2E_TEST_SENTRY_PROJECT: 'sentry-javascript-e2e-tests'
1041+
# The `runtime` of a runtime variant, see dev-packages/e2e-tests/README.md
1042+
RUNTIME: ${{ matrix.runtime }}
10411043
strategy:
10421044
fail-fast: false
10431045
matrix: ${{ fromJson(needs.job_build.outputs.e2e-matrix) }}
@@ -1056,7 +1058,7 @@ jobs:
10561058
- name: Set up Bun
10571059
if:
10581060
matrix.test-application == 'node-exports-test-app' || contains(matrix.test-application, 'bun') ||
1059-
contains(matrix.label, 'bun')
1061+
matrix.runtime == 'bun'
10601062
uses: oven-sh/setup-bun@v2
10611063
with:
10621064
bun-version: '1.3.14'
@@ -1067,7 +1069,7 @@ jobs:
10671069
use-installer: true
10681070
token: ${{ secrets.GITHUB_TOKEN }}
10691071
- name: Set up Deno
1070-
if: contains(matrix.test-application, 'deno') || contains(matrix.label, 'deno')
1072+
if: contains(matrix.test-application, 'deno') || matrix.runtime == 'deno'
10711073
uses: denoland/setup-deno@v2.0.5
10721074
with:
10731075
deno-version: ${{ matrix.deno-version || 'v2.8.3' }}
@@ -1177,6 +1179,8 @@ jobs:
11771179
# Used by test apps that deploy a real Cloudflare Worker, e.g. cloudflare-workers-send-to-sentry
11781180
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
11791181
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
1182+
# The `runtime` of a runtime variant, see dev-packages/e2e-tests/README.md
1183+
RUNTIME: ${{ matrix.runtime }}
11801184
strategy:
11811185
fail-fast: false
11821186
matrix: ${{ fromJson(needs.job_build.outputs.e2e-matrix-optional) }}
@@ -1193,8 +1197,15 @@ jobs:
11931197
uses: actions/setup-node@v7
11941198
with:
11951199
node-version-file: 'dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}/package.json'
1200+
- name: Set up Bun
1201+
if:
1202+
matrix.test-application == 'node-exports-test-app' || contains(matrix.test-application, 'bun') ||
1203+
matrix.runtime == 'bun'
1204+
uses: oven-sh/setup-bun@v2
1205+
with:
1206+
bun-version: '1.3.14'
11961207
- name: Set up Deno
1197-
if: matrix.test-application == 'deno'
1208+
if: contains(matrix.test-application, 'deno') || matrix.runtime == 'deno'
11981209
uses: denoland/setup-deno@v2.0.5
11991210
with:
12001211
deno-version: ${{ matrix.deno-version || 'v2.8.3' }}

‎AGENTS.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ Uses **Git Flow** (see `docs/gitflow.md`).
7676
Runtime packages (`node`, `cloudflare`, ...) re-export from
7777
`@sentry/server-utils` rather than defining their own.
7878

79+
- `Sentry.init()` follows one rule for repeated calls: the first call wins. See
80+
`docs/repeated-init.md` before you add or change an `init()`.
81+
7982
## Linting & Formatting
8083

8184
- This project uses **Oxlint** and **Oxfmt** — NOT ESLint or Prettier

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@
9090

9191
Work in this release was contributed by @Shubham-Padkonde and @tobias-schnabel. Thank you for your contributions!
9292

93+
- **feat(core)**: `Sentry.init()` now warns when it runs while a client is still active. For now, the new client still replaces the active client, but the active client is not closed, so state from both can mix. Call `Sentry.init()` once, or call `await Sentry.close()` before you call it again. `Sentry.close()` now unbinds the client it closes, so after `close()`, `getClient()` returns `undefined`, `isInitialized()` returns `false`, and a later `init()` sets up a new client. In `@sentry/cloudflare`, later requests no longer reuse the isolate's cached client once it is closed or closing. On the server, `@sentry/nextjs` and `@sentry/remix` now return the active client from a repeated `init()` call, not `undefined`.
94+
9395
## 11.2.0
9496

9597
### Important Changes

‎dev-packages/browser-integration-tests/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"@sentry/browser": "11.4.0",
6464
"@sentry/replay": "11.4.0",
6565
"@sentry/opentelemetry": "11.4.0",
66-
"@sentry/conventions": "0.25.0",
66+
"@sentry/conventions": "0.26.0",
6767
"@supabase/supabase-js": "2.109.0",
6868
"axios": "1.20.0",
6969
"babel-loader": "^10.1.1",

‎dev-packages/browser-integration-tests/suites/errors/fetch-enhance-messages-off/init.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as Sentry from '@sentry/browser';
33
window.Sentry = Sentry;
44

55
Sentry.init({
6-
traceLifecycle: 'static',
76
dsn: 'https://public@dsn.ingest.sentry.io/1337',
87
enhanceFetchErrorMessages: false,
98
});

‎dev-packages/browser-integration-tests/suites/errors/fetch-enhance-messages-report-only/init.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as Sentry from '@sentry/browser';
33
window.Sentry = Sentry;
44

55
Sentry.init({
6-
traceLifecycle: 'static',
76
dsn: 'https://public@dsn.ingest.sentry.io/1337',
87
enhanceFetchErrorMessages: 'report-only',
98
});

‎dev-packages/browser-integration-tests/suites/errors/fetch/init.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ import * as Sentry from '@sentry/browser';
33
window.Sentry = Sentry;
44

55
Sentry.init({
6-
traceLifecycle: 'static',
76
dsn: 'https://public@dsn.ingest.sentry.io/1337',
87
});

‎dev-packages/browser-integration-tests/suites/feedback/attachTo/init.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ window.Sentry = Sentry;
1010
window.feedback = feedback;
1111

1212
Sentry.init({
13-
traceLifecycle: 'static',
1413
dsn: 'https://public@dsn.ingest.sentry.io/1337',
1514
integrations: [feedback],
1615
});

0 commit comments

Comments
 (0)