Skip to content

Commit 052a7a8

Browse files
committed
fix(contract): tolerate transient port-file read denials in the 0h self-test
On Windows the fixture server's atomic port publish (os.replace) — or a first-touch AV scan of the fresh file, with Defender ACTIVE on the VM — briefly denies the read: is_file() is true, read_text() raises PermissionError, and the poll loop crashed the whole contract with a bare traceback (observed on the VM once the 0e/0h needle fixes let the chain reach this self-test at all). Treat an unreadable-yet port file as not-ready and keep polling inside the existing deadline. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 1d822c8 commit 052a7a8

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎tests/test_smoke_fixture_contract.sh‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,13 @@ if helper.is_file():
381381
deadline = time.monotonic() + 30
382382
while time.monotonic() < deadline:
383383
if port_file.is_file():
384-
text = port_file.read_text(encoding="ascii").strip()
384+
try:
385+
text = port_file.read_text(encoding="ascii").strip()
386+
except OSError:
387+
# Windows: the atomic replace publishing the port
388+
# (or a first-touch AV scan of the fresh file)
389+
# briefly denies the read — not ready yet.
390+
text = ""
385391
if text:
386392
port = int(text)
387393
break
@@ -474,7 +480,12 @@ if helper.is_file():
474480
dns_deadline = time.monotonic() + 20
475481
while time.monotonic() < dns_deadline:
476482
if dns_port_file.is_file():
477-
dns_text = dns_port_file.read_text(encoding="ascii").strip()
483+
try:
484+
dns_text = dns_port_file.read_text(encoding="ascii").strip()
485+
except OSError:
486+
# Windows: replace-in-flight / first-touch AV scan —
487+
# not ready yet (see the port poll above).
488+
dns_text = ""
478489
if dns_text:
479490
dns_port = int(dns_text)
480491
break

0 commit comments

Comments
 (0)