Skip to content

Conversation

@danielroe
Copy link
Member

No description provided.

@vercel
Copy link

vercel bot commented Feb 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Feb 10, 2026 1:08am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Feb 10, 2026 1:08am
npmx-lunaria Ignored Ignored Feb 10, 2026 1:08am

Request Review

@codecov
Copy link

codecov bot commented Feb 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 8, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This pull request adds JSON fallback support to ISR. modules/isr-fallback.ts defines htmlFallback = 'spa.prerender-fallback.html' and jsonFallback = 'payload-fallback.json', writes the existing HTML fallback and a supplementary {} JSON fallback file per path, and uses the htmlFallback constant when computing output paths. nuxt.config.ts changes getISRConfig from (expirationSeconds, fallback = false) to (expirationSeconds, options: ISRConfigOptions = {}), introduces ISRConfigOptions { fallback?: 'html' | 'json' }, and updates per-route ISR entries to request either html or json fallbacks (adding _payload.json routes and JSON content-type headers when selected).

Possibly related PRs

  • fix: provide payload fallback json #1186: Implements the same code-level changes—adding a JSON payload fallback in modules/isr-fallback.ts and updating getISRConfig (signature, ISRConfigOptions, and per-route fallback handling) in nuxt.config.ts.
  • perf: use spa fallback on cold cache #878: Earlier change to the ISR fallback module and getISRConfig helper that this PR extends by adding the JSON payload fallback and new options.fallback = 'json'.
🚥 Pre-merge checks | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request lacks a description entirely, making it impossible to assess whether the author's intent aligns with the changeset. Add a pull request description explaining the purpose of introducing payload fallback JSON handling, the problem being solved, and how the ISR configuration changes affect route handling.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/payload-fallback

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

nuxt.config.ts Outdated
Comment on lines 288 to 297
interface ISRConfigOptions {
fallback?: 'html' | 'json'
}
function getISRConfig(expirationSeconds: number, options: ISRConfigOptions = {}) {
if (options.fallback) {
return {
expiration: expirationSeconds,
fallback: 'spa.prerender-fallback.html',
fallback:
options.fallback === 'html' ? 'spa.prerender-fallback.html' : 'payload-fallback.json',
} as { expiration: number }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, find the nuxt.config.ts file
find . -name "nuxt.config.ts" -type f

Repository: npmx-dev/npmx.dev

Length of output: 99


🏁 Script executed:

# Check the file size first
wc -l ./nuxt.config.ts

# Then read lines 280-305 to get full context
sed -n '280,305p' ./nuxt.config.ts

Repository: npmx-dev/npmx.dev

Length of output: 604


🏁 Script executed:

# Check if getISRConfig is called elsewhere
rg "getISRConfig" ./nuxt.config.ts

# Also check for any imports or exports
rg "getISRConfig" . --type ts --type tsx

Repository: npmx-dev/npmx.dev

Length of output: 927


🏁 Script executed:

# Check the TypeScript strict settings to confirm strict type-safety is enforced
cat ./tsconfig.json | grep -A 20 '"strict"'

Repository: npmx-dev/npmx.dev

Length of output: 43


🏁 Script executed:

# Check if tsconfig.json exists
ls -la tsconfig.json 2>&1 || echo "File not found"

# Try reading the file
cat tsconfig.json 2>&1 | head -50

Repository: npmx-dev/npmx.dev

Length of output: 442


Remove the type assertion to restore type safety.

The as { expiration: number } cast on line 296 hides the fallback field from the return type, even though the function includes it in the returned object when options.fallback is provided. This violates strict type-safety requirements. Define an explicit return type that includes an optional fallback property and remove the assertion.

🔧 Proposed fix
 interface ISRConfigOptions {
   fallback?: 'html' | 'json'
 }
+interface ISRConfig {
+  expiration: number
+  fallback?: 'spa.prerender-fallback.html' | 'payload-fallback.json'
+}
-function getISRConfig(expirationSeconds: number, options: ISRConfigOptions = {}) {
+function getISRConfig(expirationSeconds: number, options: ISRConfigOptions = {}): ISRConfig {
   if (options.fallback) {
     return {
       expiration: expirationSeconds,
       fallback:
         options.fallback === 'html' ? 'spa.prerender-fallback.html' : 'payload-fallback.json',
-    } as { expiration: number }
+    }
   }
   return {
     expiration: expirationSeconds,
   }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
interface ISRConfigOptions {
fallback?: 'html' | 'json'
}
function getISRConfig(expirationSeconds: number, options: ISRConfigOptions = {}) {
if (options.fallback) {
return {
expiration: expirationSeconds,
fallback: 'spa.prerender-fallback.html',
fallback:
options.fallback === 'html' ? 'spa.prerender-fallback.html' : 'payload-fallback.json',
} as { expiration: number }
interface ISRConfigOptions {
fallback?: 'html' | 'json'
}
interface ISRConfig {
expiration: number
fallback?: 'spa.prerender-fallback.html' | 'payload-fallback.json'
}
function getISRConfig(expirationSeconds: number, options: ISRConfigOptions = {}): ISRConfig {
if (options.fallback) {
return {
expiration: expirationSeconds,
fallback:
options.fallback === 'html' ? 'spa.prerender-fallback.html' : 'payload-fallback.json',
}
}
return {
expiration: expirationSeconds,
}
}

@serhalp
Copy link
Contributor

serhalp commented Feb 8, 2026

For my own nuxt edification, would you mind explaining what this does and what this PR is solving for? 🙏🏼

@vercel
Copy link

vercel bot commented Feb 10, 2026

Deployment failed with the following error:

Header at index 0 has invalid `source` regular expression "**/*_payload.json".

Learn More: https://vercel.link/invalid-route-source-pattern

@danielroe danielroe marked this pull request as ready for review February 10, 2026 01:10
@danielroe danielroe merged commit 3ea47eb into main Feb 10, 2026
20 checks passed
@danielroe danielroe deleted the fix/payload-fallback branch February 10, 2026 01:10
@danielroe
Copy link
Member Author

@serhalp this provides fallback json files to speed up initial fetching of payloads when the cache is cold.

it's not a nuxt thing in particular, and we do need to solve by speeding up the rendering of payloads for package pages, instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants