Repository navigation
Read .NET driver log files with shared access - #2865
Conversation
The Chrome, Edge, Firefox and IE log tests read the driver log right after driver.Quit() with File.ReadLines/ReadAllLines, which request exclusive read access. On Windows the driver process can still hold the file open for writing, so the read fails with "The process cannot access the file ... because it is being used by another process". Edge already retried for 10 seconds and still failed, so waiting does not help. Add a LogFile helper that opens the log with FileShare.ReadWrite | FileShare.Delete (as Troubleshooting/LoggingTest.cs already does), and a TryDelete for cleanup that ignores a still-locked file. Each call site is swapped on the same line, so gh-codeblock line ranges in the docs are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NUg261RgRsNLfjAXhj3FqP
PR Summary by QodoRead .NET driver logs with shared file access
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
✅ Deploy Preview for selenium-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Code Review by Qodo
1.
|
The OS does not clean up %TEMP% on Windows, so a log that is still locked during test cleanup was left behind. Retry the delete for up to two seconds and write a warning to stderr if the file is still locked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NUg261RgRsNLfjAXhj3FqP
|
Update: on 9891d80 the same job passed with the same nightly ( Generated by Claude Code |
|
Code review by qodo was updated up to the latest commit 9891d80 |
Thanks for contributing to the Selenium site and documentation!
A PR well described will help maintainers to review and merge it quickly
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, and help reviewers by making them as simple and short as possible.
Description
examples/dotnet/SeleniumDocs/LogFile.cswith:LogFile.ReadLines(path): opens the log withFileShare.ReadWrite | FileShare.Delete, the same approachTroubleshooting/LoggingTest.csalready uses;LogFile.TryDelete(path): cleanup that ignores a log file still locked by the driver.LogFile.ReadLines(...)instead ofFile.ReadLines(...)andLogFile.TryDelete(...)instead ofFile.Delete(...)in cleanup. Edge's existingReadLogLineshelper now reads throughLogFile.ReadLines.gh-codeblockline range in the docs moves; I checked that none of the changed lines are referenced by the docs.Motivation and Context
On Windows, the driver log tests (
ChromeTest.LogsLevel/ConfigureDriverLogs,EdgeTest.LogsToFile/LogsLevel/ConfigureDriverLogs) intermittently fail with:The tests read the log right after
driver.Quit()withFile.ReadLines/File.ReadAllLines, which request exclusive read access while the driver process may still hold the file open for writing. Edge already retried the read for 10 seconds and still failed, so waiting doesn't help; opening the file with shared access does. These failures are a large part of the daily red .NET runs on Windows and are blocking #2863.Complements #2864 (retry only failed tests): that one stops flaky tests from costing a full re-run; this one removes this flake.
Types of changes
Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_01NUg261RgRsNLfjAXhj3FqP
Generated by Claude Code