Skip to content

Fix flaky Windows test: lost log file entries when something logs after deactivation - #2339

Open
louis-johnston-db wants to merge 1 commit into
release/3.xfrom
factory/winflake/extension-8da820
Open

louis-johnston-db wants to merge 1 commit into
release/3.xfrom
factory/winflake/extension-8da820

Conversation

@louis-johnston-db

Copy link
Copy Markdown
Contributor

Changes

  • JsonFileSink.write (src/platform/log.ts) skips an entry once the stream has ended (writableEnded). A write after end() makes Node destroy the stream, which drops the entries it hasn't flushed yet. Something can log after deactivation: Unity Gateway's auto sign-in logs a warning when deactivation stops the profile load. When the log file was slow to open, the end of the log was lost. That is what made extension.test.ts > activate > writes the profile's token nowhere time out waiting for the log line on Windows. Users lost the end of their log file the same way.
  • New test in src/platform/log.test.ts: an entry still buffered when the sink is disposed reaches the file even when something logs after dispose.

This is a production change: the race is in the product (late writes after deactivation), not in the test.

Production change: The race is in the product: JsonFileSink wrote to its stream after dispose() had ended it, and Node then destroyed the stream and dropped the entries it hadn't flushed yet. Anything that logs after deactivation (here, Unity Gateway's auto sign-in failing because the profile load was stopped) cost users the end of their log file. The guard skips only entries logged after the sink ended, which could never have been written.

Tests

  • yarn vitest run src/platform/log.test.ts src/extension.test.ts in packages/databricks-vscode: passes.
  • The new log.test.ts test fails without the guard (the buffered entry is lost) and passes with it.
  • With a local repro that slows the log file's open and the fake API's responses, so the sign-in is still running at deactivation, writes the profile's token nowhere failed before the fix and passes with it.
  • yarn oxfmt and yarn oxlint --deny-warnings on the changed files: clean.

Evidence (the factory's checks):

  • Windows CI, last 14 days: failed in 1 of 114 test-windows runs on release/3.x and its pull requests, with Linux test passing in the same runs; last seen 2026-11-17. Runs: 44049025596.
  • Linux repro (not part of this change; src/extension.repro.test.ts): failed 24 of 30 runs without the fix, 0 of 30 with it.
  • The touched test files under CPU load: 20 of 20 runs passed.
  • yarn workspace databricks test: 3118 passed, 0 failed. yarn check: passed.

This pull request and its description were written by Isaac.

…er deactivation

JsonFileSink.write now skips entries once its stream has ended. A write after end() raised ERR_STREAM_WRITE_AFTER_END, and the fs.WriteStream's autoDestroy then dropped every entry still buffered. Unity Gateway's auto sign-in logs a warning after deactivation, so on Windows, where the file opens and requests run slower, the line the test waits for was lost. Same fix as attempt 1, reshaped so the diff no longer ends on a whitespace-only context line, which the controller's copy of the patch had trimmed (the corrupt patch at line 44).

<!-- vscode-factory:item=winflake:8da8201393.3 -->

Co-authored-by: Isaac <no-reply@databricks.com>

This branch was previously deployed

1 inactive deployment
test-trigger-is — f03a6729 Deployed Nov 22, 2026 by louis-johnston-db via Trigger Tests #2590
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant