Skip to content

Commit

Permalink
[Turbopack] write action manifest atomically (#68538)
Browse files Browse the repository at this point in the history
### Why?

Avoid reading in progress files
  • Loading branch information
sokra authored Aug 13, 2024
1 parent 7302f35 commit feeffb3
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/next/src/server/dev/turbopack/manifest-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
TURBOPACK_CLIENT_MIDDLEWARE_MANIFEST,
} from '../../../shared/lib/constants'
import { join, posix } from 'path'
import { readFile, writeFile } from 'fs/promises'
import { readFile } from 'fs/promises'
import type { SetupOpts } from '../../lib/router-utils/setup-dev-bundler'
import { deleteCache } from '../require-cache'
import { writeFileAtomic } from '../../../lib/fs/write-atomic'
Expand Down Expand Up @@ -178,11 +178,10 @@ export class TurbopackManifestLoader {
const json = JSON.stringify(actionManifest, null, 2)
deleteCache(actionManifestJsonPath)
deleteCache(actionManifestJsPath)
await writeFile(actionManifestJsonPath, json, 'utf-8')
await writeFile(
await writeFileAtomic(actionManifestJsonPath, json)
await writeFileAtomic(
actionManifestJsPath,
`self.__RSC_SERVER_MANIFEST=${JSON.stringify(json)}`,
'utf-8'
`self.__RSC_SERVER_MANIFEST=${JSON.stringify(json)}`
)
}

Expand Down

0 comments on commit feeffb3

Please sign in to comment.