{"version":3,"file":"utils.js","names":["_isMainThread"],"sources":["../src/utils.ts"],"sourcesContent":["import { isMainThread as _isMainThread, threadId } from 'node:worker_threads'\n\n// since vitest run all cases in worker thread, we should compatible with it to pass E2E tests\n\n// @ts-expect-error use Vitest\nexport const isInVitestEntryThread = threadId === 0 && process.env.VITEST\nexport const isMainThread = _isMainThread || isInVitestEntryThread\n\n// Filesystem errors that are expected during watching: editors commonly save\n// via an atomic rename (write temp file, then replace), and branch switches or\n// deletions can remove a file between a watcher event firing and the checker\n// reading it. In that window the path briefly doesn't exist (or isn't readable\n// yet), so a `change`/`unlink` handler can hit one of these codes. They are\n// transient and should not crash the dev server — the next stable write fires a\n// fresh event. See #461 for the same race in the ignore-check path.\nconst TRANSIENT_FS_ERROR_CODES = new Set(['ENOENT', 'EBUSY', 'EPERM', 'EACCES'])\n\nexport function isTransientFsError(error: unknown): boolean {\n if (typeof error !== 'object' || error === null) return false\n const { code } = error as NodeJS.ErrnoException\n return code !== undefined && TRANSIENT_FS_ERROR_CODES.has(code)\n}\n\n// `.catch` handler for watcher-triggered checker work. Ignore the transient FS\n// errors that happen when a file is removed/replaced mid-read, and rethrow\n// anything else so genuine failures still surface instead of being hidden.\nexport function ignoreTransientFsError(error: unknown): void {\n if (isTransientFsError(error)) return\n throw error\n}\n"],"mappings":";;AAKA,MAAa,wBAAwB,aAAa,KAAK,QAAQ,IAAI;AACnE,MAAa,eAAeA,kBAAiB;AAS7C,MAAM,2BAA2B,IAAI,IAAI;CAAC;CAAU;CAAS;CAAS;AAAQ,CAAC;AAE/E,SAAgB,mBAAmB,OAAyB;CAC1D,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,MAAM,EAAE,SAAS;CACjB,OAAO,SAAS,KAAA,KAAa,yBAAyB,IAAI,IAAI;AAChE;AAKA,SAAgB,uBAAuB,OAAsB;CAC3D,IAAI,mBAAmB,KAAK,GAAG;CAC/B,MAAM;AACR"}