{"record":{"id":"149f23d8b6e9a743","repo":"bazelbuild/bazel","slug":"waiting-for-previous-bazel-server-s-log-file-to-cl","errorCode":null,"errorMessage":"Waiting for previous Bazel server's log file to close (waited %d seconds, waiting at most %d)\n","messagePattern":"Waiting for previous Bazel server's log file to close \\(waited (.+?) seconds, waiting at most (.+?)\\)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"src/main/cpp/blaze_util_windows.cc","lineNumber":599,"sourceCode":"      if (daemon_out_append &&\n          !SetFilePointerEx(handle, {}, nullptr, FILE_END)) {\n        fprintf(stderr, \"Could not seek to end of file (%s)\\n\",\n                path.AsPrintablePath().c_str());\n        return INVALID_HANDLE_VALUE;\n      }\n      return handle;\n    }\n    if (GetLastError() != ERROR_SHARING_VIOLATION &&\n        GetLastError() != ERROR_LOCK_VIOLATION) {\n      // Some other error occurred than the file being open; bail out.\n      break;\n    }\n\n    // The file is still held open, the server is shutting down. There's a\n    // chance that another process holds it open, we don't know; in that case\n    // we just exit after the timeout expires.\n    if (waited == 5 || waited == 10 || waited == 30) {\n      fprintf(stderr,\n              \"Waiting for previous Bazel server's log file to close \"\n              \"(waited %d seconds, waiting at most %d)\\n\",\n              waited, timeout_sec);\n    }\n    Sleep(1000);\n  }\n  return INVALID_HANDLE_VALUE;\n}\n\nclass ProcessHandleBlazeServerStartup : public BlazeServerStartup {\n public:\n  ProcessHandleBlazeServerStartup(HANDLE _proc) : proc(_proc) {}\n\n  bool IsStillAlive() override {\n    FILETIME dummy1, exit_time, dummy2, dummy3;\n    return GetProcessTimes(proc, &dummy1, &exit_time, &dummy2, &dummy3) &&\n           exit_time.dwHighDateTime == 0 && exit_time.dwLowDateTime == 0;\n  }","sourceCodeStart":581,"sourceCodeEnd":617,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/main/cpp/blaze_util_windows.cc#L581-L617","documentation":"On Windows, when the previous Bazel server's jvm.out is still open (sharing violation), the client polls CreateFileW once per second up to timeout_sec and prints this progress notice at 5, 10, and 30 elapsed seconds. It is not a failure by itself: it reports that Bazel is waiting for the dying server to release its log file, and if the timeout expires it gives up and returns INVALID_HANDLE_VALUE.","triggerScenarios":"Immediately rerunning a Bazel command after interrupting the previous one while the JVM server is still flushing and exiting; two clients racing on the same output_base; the server hung in shutdown holding the log handle longer than the wait timeout.","commonSituations":"CI scripts that kill bazel and restart at once; interactive Ctrl-C followed by a quick rerun; overloaded Windows machines where the JVM takes tens of seconds to exit.","solutions":["Simply wait: the message is informational and the wait usually succeeds once the old server exits.","If waits keep timing out, run 'bazel shutdown', then confirm no java process holds jvm.out (Resource Monitor / handle.exe) before rerunning.","For scripted restarts, add a few seconds of delay or poll 'bazel info' instead of hammering the same output_base.","Give each concurrent job its own --output_base to avoid two clients contending for one server log."],"exampleFix":"# before (CI): bazel kill %BAZEL_SERVER% ; bazel build //pkg\n# after: bazel shutdown && sleep 10 && bazel build //pkg\n# or isolate: bazel --output_base=C:/_ci/%BUILD_ID% build //pkg","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat the message as progress, not failure; do not kill Bazel while it waits.","Insert a small delay between 'bazel shutdown' and the next build in scripts.","Use one output_base per concurrent client to avoid log-file contention.","If waits exceed 30s regularly, investigate why the JVM server is slow to exit (heap dumps, antivirus)."],"tags":["windows","server","log-file","wait","sharing-violation","restart"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}