Skip to content

sliceMap doesn't seem to work in a 404 page created via createPage #38263

@dbismut

Description

@dbismut

Preliminary Checks

Description

It seems like there is an issue with slice maps and a 404 page that would be created with createPages rather than having a 404.js file in the pages directory. My use case is similar to the one discussed here, with the 404 page context needing to be fed with graphql data.

I also decided to try the new Slice feature (which is incredible, thank you for this). Since my website is localized, I'm also using the slices attribute in createPages as described here in order to have localized slices.

However, it looks like when the 404 page is reached when redirecting to it when a page doesn't exist, the slices alias don't seem to work properly.

Reproduction Link

https://codesandbox.io/p/sandbox/admiring-lucy-cz3nm4

Steps to Reproduce

  1. Navigate to a non existing page (ie https://cz3nm4-8000.csb.app/awol)
  2. The dev 404 page should show
  3. Click on Preview custom 404 page
  4. You should get an error with the slice not existing

Expected Result

However, if you go to the 404 page https://cz3nm4-8000.csb.app/404 everything behaves properly.

image

Actual Result

Mapped slice is missing:

image

Environment

Codesandbox env:

  System:
    OS: Linux 5.15 Debian GNU/Linux 11 (bullseye) 11
(bullseye)
    CPU: (2) x64 AMD EPYC
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 18.16.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.5.1 - /usr/local/bin/npm
  npmPackages:
    gatsby: ^5.11.0 => 5.9.1

Config Flags

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: confirmedIssue with steps to reproduce the bug that’s been verified by at least one reviewer.topic: coreRelates to Gatsby's core (e.g. page loading, reporter, state machine)type: bugAn issue or pull request relating to a bug in Gatsby

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions