From 04f284afab0e6d2fc73990b57dcd3c1cd7ea8513 Mon Sep 17 00:00:00 2001 From: Nicolas Hrubec Date: Sat, 31 Oct 2026 10:29:12 +0100 Subject: [PATCH 1/2] chore: Add Bugbot guidance for cold imports in unit tests Co-Authored-By: OpenAI Codex --- .cursor/BUGBOT.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.cursor/BUGBOT.md b/.cursor/BUGBOT.md index 4a9d0bd65ef4..8cfa1fcd02fd 100644 --- a/.cursor/BUGBOT.md +++ b/.cursor/BUGBOT.md @@ -103,6 +103,12 @@ Keep reviews high-signal. Prefer actionable, high-confidence findings over specu - Only waiting for a request, after an action is performed. Instead, start waiting, perform action, await request promise. - 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. - Timeouts or sleeps in tests. Instead suggest concrete events or other signals to wait on. +- Flag avoidable cold imports inside unit tests or their helpers, especially + broad entry points loaded after `vi.resetModules()`. Module loading can + exhaust the test timeout before assertions run. Prefer static imports, + narrower modules, or setup hooks while preserving isolation and mock order. + Exempt imports whose timing, side effects, or exports are being tested. + Do not flag dynamic imports without evidence of unnecessary loading. - Flag usage of `getFirstEnvelope*`, `getMultipleEnvelope*` or related test helpers in E2E tests. These are NOT reliable anymore. Instead suggest helpers like `waitForTransaction`, `waitForError`, `waitForSpans`, etc. - Flag any new or modified `docker-compose.yml` under `dev-packages/node-integration-tests/suites/` where a service does not define a `healthcheck:`. The runner uses `docker compose up --wait` and relies on healthchecks to know when services are actually ready; without one the test will race the service's startup. - Flag new Cloudflare tests that wrap the worker by hand with `withSentry`, `instrumentDurableObjectWithSentry`, `instrumentAgentWithSentry` or `instrumentWorkflowWithSentry`. This covers new suites under `dev-packages/cloudflare-integration-tests/suites/`, new E2E apps under `dev-packages/e2e-tests/test-applications/` that run on Cloudflare, and new Cloudflare variants of existing E2E apps (an entry in `sentryTest.variants` of the app's `package.json`, for example `hono-4 (cloudflare)`). App names do not always start with `cloudflare-`. Recommend the Sentry Cloudflare Vite plugin instead: `plugins: [cloudflare(), sentryCloudflareVitePlugin()]` in `vite.config.*` (`sentryCloudflareVitePlugin` from `@sentry/cloudflare/vite`), and the SDK options in an `instrument.server.ts` next to the worker entry that default-exports `defineCloudflareOptions(...)`. Do not flag tests whose purpose is to test one of these wrappers, or apps that do not build with Vite (for example Next.js on OpenNext). From 82fb1ec972cca5bdfefc71185a6ccfbcf1211c41 Mon Sep 17 00:00:00 2001 From: Nicolas Hrubec Date: Sat, 31 Oct 2026 10:33:36 +0100 Subject: [PATCH 2/2] chore: Generalize Bugbot cold-import guidance to timed test callbacks Co-Authored-By: OpenAI Codex --- .cursor/BUGBOT.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.cursor/BUGBOT.md b/.cursor/BUGBOT.md index 8cfa1fcd02fd..afbd17c05ff9 100644 --- a/.cursor/BUGBOT.md +++ b/.cursor/BUGBOT.md @@ -103,12 +103,12 @@ Keep reviews high-signal. Prefer actionable, high-confidence findings over specu - Only waiting for a request, after an action is performed. Instead, start waiting, perform action, await request promise. - 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. - Timeouts or sleeps in tests. Instead suggest concrete events or other signals to wait on. -- Flag avoidable cold imports inside unit tests or their helpers, especially - broad entry points loaded after `vi.resetModules()`. Module loading can - exhaust the test timeout before assertions run. Prefer static imports, - narrower modules, or setup hooks while preserving isolation and mock order. - Exempt imports whose timing, side effects, or exports are being tested. - Do not flag dynamic imports without evidence of unnecessary loading. +- Flag cold module loading inside timed test callbacks or their helpers when + it can safely run during collection or setup. It can exhaust the timeout + before the behavior under test runs. Prefer static imports, narrower + modules, or setup hooks while preserving isolation and mock order. + Preserve imports whose evaluation timing is itself being tested. + Only flag concrete avoidable loading, not dynamic imports in general. - Flag usage of `getFirstEnvelope*`, `getMultipleEnvelope*` or related test helpers in E2E tests. These are NOT reliable anymore. Instead suggest helpers like `waitForTransaction`, `waitForError`, `waitForSpans`, etc. - Flag any new or modified `docker-compose.yml` under `dev-packages/node-integration-tests/suites/` where a service does not define a `healthcheck:`. The runner uses `docker compose up --wait` and relies on healthchecks to know when services are actually ready; without one the test will race the service's startup. - Flag new Cloudflare tests that wrap the worker by hand with `withSentry`, `instrumentDurableObjectWithSentry`, `instrumentAgentWithSentry` or `instrumentWorkflowWithSentry`. This covers new suites under `dev-packages/cloudflare-integration-tests/suites/`, new E2E apps under `dev-packages/e2e-tests/test-applications/` that run on Cloudflare, and new Cloudflare variants of existing E2E apps (an entry in `sentryTest.variants` of the app's `package.json`, for example `hono-4 (cloudflare)`). App names do not always start with `cloudflare-`. Recommend the Sentry Cloudflare Vite plugin instead: `plugins: [cloudflare(), sentryCloudflareVitePlugin()]` in `vite.config.*` (`sentryCloudflareVitePlugin` from `@sentry/cloudflare/vite`), and the SDK options in an `instrument.server.ts` next to the worker entry that default-exports `defineCloudflareOptions(...)`. Do not flag tests whose purpose is to test one of these wrappers, or apps that do not build with Vite (for example Next.js on OpenNext).