Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

ISR pages are regenerated with wrong name when prefetching #2349

@falsyzoo

Description

@falsyzoo

Issue Summary

When Next.js is prefetching an ISR page / when a request is made to https://example.com/_next/data/.../page.json and the page is queued for regeneration, the page is stored to static-pages/.../pageon.html / _next/data/.../pageon.json
(instead of static-pages/.../page.html / _next/data/.../page.json).

I suspect that .replace(".js", "") is the culprit (as .json includes .js) but I'm not sure if this replacement is actually necessary.
(Are any situations where an ISR page has a .js extension?)

const normalizedUri = decodeURI(regenerationEvent.pageS3Path)
.replace(`static-pages/${manifest.buildId}`, "")
.replace(".js", "");

Actual behavior

Next.js prefetch / request to _next/data/...

SQS event:

{
  "region": "eu-west-1",
  "bucketName": "example",
  "pageS3Path": "/_next/data/KL5A2qpf1jF1Q63QKlpey/en/event/coursera.json",
  "cloudFrontEventRequest": {
    "method": "GET",
    "origin": {
      "s3": {
        "authMethod": "origin-access-identity",
        "customHeaders": {},
        "domainName": "example.s3.eu-west-1.amazonaws.com",
        "path": "",
        "region": "eu-west-1"
      }
    },
    "querystring": "",
    "uri": "/_next/data/KL5A2qpf1jF1Q63QKlpey/en/event/coursera.json"
  },
  "basePath": "",
  "pagePath": "pages/event/[slug].js"
}

Generated objects:
static-pages/KL5A2qpf1jF1Q63QKlpey/en/event/courseraon.html
_next/data/KL5A2qpf1jF1Q63QKlpey/en/event/courseraon.json

Normal request

SQS event:

{
  "region": "eu-west-1",
  "bucketName": "example",
  "pageS3Path": "/en/event/coursera.html",
  "cloudFrontEventRequest": {
    "method": "GET",
    "origin": {
      "s3": {
        "authMethod": "origin-access-identity",
        "customHeaders": {},
        "domainName": "example.s3.eu-west-1.amazonaws.com",
        "path": "/static-pages/KL5A2qpf1jF1Q63QKlpey",
        "region": "eu-west-1"
      }
    },
    "querystring": "",
    "uri": "/en/event/coursera"
  },
  "basePath": "",
  "pagePath": "pages/event/[slug].js"
}

Generated objects:
static-pages/KL5A2qpf1jF1Q63QKlpey/en/event/coursera.html
_next/data/KL5A2qpf1jF1Q63QKlpey/en/event/coursera.json

Expected behavior

In both cases the generated objects should be stored to
static-pages/KL5A2qpf1jF1Q63QKlpey/en/event/coursera.html
_next/data/KL5A2qpf1jF1Q63QKlpey/en/event/coursera.json

Steps to reproduce

Screenshots/Code/Configuration/Logs

image

Versions

  • OS/Environment:
  • @sls-next/serverless-component version: 3.6.0
  • Next.js version: 12.0.8

Additional context

Checklist

  • You have reviewed the README and FAQs, which answers several common questions.
  • You have reviewed our DEBUGGING wiki and have tried your best to include complete information and reproduction steps (including your configuration) as is possible. As there is only one maintainer (who maintains this in his free time) and thus very limited resources, if you have time, please try to debug the issue a bit yourself if possible.
  • You have first tried using the most recent latest or alpha @sls-next/serverless-component release version, which may have already fixed your issue or implemented the feature you are trying to use. Note that the old serverless-next.js component and the serverless-next.js plugin are deprecated and no longer maintained.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions