Skip to content

Vite returns 504 Outdated Optimize Dep for non-existing resource #13506

@alex-kinokon

Description

@alex-kinokon

Describe the bug

Given the following dynamic import within a dependency located on localhost:3000/node_modules/.vite/deps/chunk-HCOQKIU7.js:

// node_modules/@blueprintjs/icons/lib/esnext/iconLoader.js
var defaultIconPathsLoader = async(name,size)=>{
    return (await import(/* webpackInclude: /\.js$/ */
    /* webpackMode: "lazy-once" */
    `./generated/${size}px/paths/${name}`)).default;
}

There are two problems:

  1. The import path does not resolve correctly, because it’s no longer relative to the original module path. Duplicate of Dynamic imports with variables in a dependency are not processed at all #6179.
  2. When vite fails to resolve the path, it returns an erroneous error message (504 Outdated Optimize Dep, please reload the page) instead of 404. The culprit code is here.

Reproduction

https://codesandbox.io/p/sandbox/hopeful-brattain-gz4per

Steps to reproduce

See CodeSandbox link above.

System Info

System:
    OS: Linux 5.15 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
    CPU: (2) x64 AMD EPYC
    Memory: 474.37 MB / 2.01 GB
    Container: Yes
    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:
    @vitejs/plugin-react: ^4.0.0 => 4.0.0 
    vite: ^4.3.9 => 4.3.9

Used Package Manager

yarn

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: deps optimizerEsbuild Dependencies Optimizationp2-nice-to-haveNot breaking anything but nice to have (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions