fix(nextjs-config): snapshot dist files before invoking sourcemap CLI - #4681
Draft
cat-ph wants to merge 1 commit into
Draft
fix(nextjs-config): snapshot dist files before invoking sourcemap CLI#4681cat-ph wants to merge 1 commit into
cat-ph wants to merge 1 commit into
Conversation
Contributor
Contributor
|
Size Change: +2.01 kB (+0.01%) Total Size: 20.7 MB 📦 View Changed
ℹ️ View Unchanged
|
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #4667.
On Next.js 16.3+,
next buildwithwithPostHogConfigcan abort withChunk ID not found(exit 1). Next 16.3 enablesturbopackFileSystemCacheForBuildby default, and Turbopack keeps writing intodistDirin the background whilerunAfterProductionCompileis running (the cache-persisting shutdown promise is only awaited at the very end of the build, after the compiler hook).@posthog/nextjs-confighands the wholedistDirtoposthog-cli sourcemap process, whose two passes (inject, then upload) each re-walk directory roots independently. A chunk pair that materializes between the two walks is found by the upload pass without an injected chunk ID, and the CLI hard-fails the whole build.Changes
processSourceMapsnow snapshots the build outputs into an explicit file list and passes it to the CLI via the existing stdin file-path mode (the same mechanism@posthog/webpack-pluginalready uses). The CLI resolves stdin once and reuses the identical set for both inject and upload, so late-appearing files can no longer fail the build.<distDir>/cachedirectory before descending: it only holds bundler caches (Turbopack filesystem cache, webpack cache), never deployable chunks, and is concurrently written by design. Deeper directories that happen to be namedcache(route output) stay included.Note: this makes the processed set deterministic; files Turbopack flushes after the snapshot are consistently untouched by both passes. The root-boundary CLI fix (materializing the walk once inside
sourcemap process) is being addressed separately in the PostHog monorepo.Release info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
runAfterProductionCompileruns before the Turbopack shutdown/cache-flush promise is awaited; unchanged on canary; no Next hook exists that runs after the flush).readdir({ recursive: true })snapshot would still traverse (and could reject on) the concurrently-written cache directory, which led to the pruning walker.