test(node-core): Fix flaky cron instrumentation test#21553
Merged
Conversation
mydea
approved these changes
Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the flaky
suites/cron/cron/test.ts > cron instrumentationtest in the Node-Core Integration Tests.Root cause
The test asserts a strict, ordered sequence of envelopes, ending with the error
check_infollowed by the errorevent:For the failing cron tick,
withMonitoremits the errorcheck_inandcaptureExceptionemits the erroreventback-to-back.captureExceptiondefers its actual transportsend(async event preparation), while the check-in is sent synchronously — so the send order is deterministic (check-in first, event second).However, this scenario was the only cron-error test still using
.withMockSentryServer(). That mock server observes envelopes in network arrival order, not send order. The two envelopes are sent close together over HTTP (potentially on different sockets), so their arrival order at the server is non-deterministic. When theeventarrives before the errorcheck_in, the runner's in-order matcher hits a type mismatch (Expected envelope item type 'check_in' but got 'event') and the test fails.Fix
Switch the scenario to
loggingTransport(and drop.withMockSentryServer()), exactly like the sibling cron-error tests in the same directory tree (node-cron/base,node-schedule) that are not flaky.loggingTransportlogs each envelope to stdout atsend()time, so the runner observes envelopes in deterministic send order, eliminating the network arrival-order race.The assertions are unchanged — the test still exercises the identical 5 envelopes (statuses,
monitor_config, trace contexts, and the error event). Only the observation mechanism changes to a deterministic one.Fixes #21254