( fullPath: string, entry: Record<string, unknown>, )
| 2732 | */ |
| 2733 | /* eslint-disable custom-rules/no-sync-fs -- sync callers (exit cleanup, materialize) */ |
| 2734 | function appendEntryToFile( |
| 2735 | fullPath: string, |
| 2736 | entry: Record<string, unknown>, |
| 2737 | ): void { |
| 2738 | const fs = getFsImplementation() |
| 2739 | const line = jsonStringify(entry) + '\n' |
| 2740 | try { |
| 2741 | fs.appendFileSync(fullPath, line, { mode: 0o600 }) |
| 2742 | } catch (error) { |
| 2743 | if (isFsInaccessible(error)) { |
| 2744 | logForDebugging( |
| 2745 | `Skipping sync transcript metadata write for ${fullPath}: ${errorMessage(error)}`, |
| 2746 | { level: 'warn' }, |
| 2747 | ) |
| 2748 | return |
| 2749 | } |
| 2750 | try { |
| 2751 | fs.mkdirSync(dirname(fullPath), { mode: 0o700 }) |
| 2752 | fs.appendFileSync(fullPath, line, { mode: 0o600 }) |
| 2753 | } catch (retryError) { |
| 2754 | if (isFsInaccessible(retryError)) { |
| 2755 | logForDebugging( |
| 2756 | `Skipping sync transcript metadata write for ${fullPath}: ${errorMessage(retryError)}`, |
| 2757 | { level: 'warn' }, |
| 2758 | ) |
| 2759 | return |
| 2760 | } |
| 2761 | throw retryError |
| 2762 | } |
| 2763 | } |
| 2764 | } |
| 2765 | |
| 2766 | /** |
| 2767 | * Sync tail read for reAppendSessionMetadata's external-writer check. |
no test coverage detected