Embroider & Vite & net::ERR_ABORTED 504 (Outdated Optimize Dep)



This content originally appeared on DEV Community and was authored by Michal Bryxí

While working on EmberJS projects, I’ve been using pre-alpha version of @embroider/app-blueprint quite a lot lately and I hit a baffling error:

1) App builds and everything works
2) Sometimes, when the dev server is restarted (ctrl+c & pnpm start), the network tab of the app fails many requests with:

GET
http://localhost:4200/node_modules/.vite/deps/ember-source_@ember_application_index__js.js?v=4536db21
net::ERR_ABORTED 504 (Outdated Optimize Dep)

3) Nothing helps: Wiping node_modules; Setting the server to run with vite --force; Getting earlier versions of the app;
4) Sometimes everything builds fine and I can develop without any issue.

Image description

I discussed this very issue on EmberJS Discord and was pointed to pay attention at the console build errors, which actually did have some weird messages in it. I just never paid attention, because initially everything built fine:

pnpm start

> nuudel-to-ics@0.0.0 start /Users/michal/pudr.com/nuudel-to-ics
> vite --force

- Building

Environment: development

- Building

- building... 



Build successful (276ms)

9:45:36 AM [vite] (client) Forced re-optimization of dependencies

Slowest Nodes (totalTime >= 5%) | Total (avg)
-+-
Babel: ember-tracked-storage-polyfill (1) | 115ms
Funnel (109) | 33ms (0 ms)
BroccoliMergeTrees (202) | 31ms (0 ms)
Babel: ember-intl (2) | 21ms (10 ms)
@embroider/compat/addons (1) | 15ms



  VITE v6.2.3  ready in 2638 ms

  ➜  Local:   http://localhost:4200/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help
✘ [ERROR] Cannot read file: /Users/michal/pudr.com/nuudel-to-ics/node_modules/.pnpm/object-inspect@1.13.4/node_modules/object-inspect/util.inspect

    node_modules/.pnpm/object-inspect@1.13.4/node_modules/object-inspect/index.js:54:26:
      54 │ var utilInspect = require('./util.inspect');
         ╵                           ~~~~~~~~~~~~~~~~

9:45:44 AM [vite] (client) error while updating dependencies:
Error: Build failed with 1 error:
node_modules/.pnpm/object-inspect@1.13.4/node_modules/object-inspect/index.js:54:26: ERROR: Cannot read file: /Users/michal/pudr.com/nuudel-to-ics/node_modules/.pnpm/object-inspect@1.13.4/node_modules/object-inspect/util.inspect
    at failureErrorWithLog (/Users/michal/pudr.com/nuudel-to-ics/node_modules/.pnpm/esbuild@0.25.1/node_modules/esbuild/lib/main.js:1477:15)
    at /Users/michal/pudr.com/nuudel-to-ics/node_modules/.pnpm/esbuild@0.25.1/node_modules/esbuild/lib/main.js:946:25
    at /Users/michal/pudr.com/nuudel-to-ics/node_modules/.pnpm/esbuild@0.25.1/node_modules/esbuild/lib/main.js:1355:9
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

So now the issue is actually about ✘ [ERROR] Cannot read file: /Users/michal/pudr.com/nuudel-to-ics/node_modules/.pnpm/object-inspect@1.13.4/node_modules/object-inspect/util.inspect resp. the package object-inspect itself. And the advice I got is to exclude it from optimisations

So that’s what I did by adding few lines to vite.config.mjs:

// vite.config.mjs

export default defineConfig({
  optimizeDeps: {
    exclude: ['object-inspect'],
  },
});

And since then the app builds and I seem to never get this error.


This content originally appeared on DEV Community and was authored by Michal Bryxí