Skip to content

Undici v6 imported by @nuxt/scripts since v1.3.4 #887

Description

@fredericDelaporte

Undici v6 is imported by @nuxt/scripts since v1.3.4 at least up to v1.3.8.

In our case, it conflicts in some hidden way with our own import of undici v8, causing our nitro plugin for enabling the cache (inexistent in v6) to fail, failing our startup, but only on actual servers, not in dev mode.

import { setGlobalDispatcher, Agent, interceptors } from 'undici';

export default defineNitroPlugin(() => {
  setGlobalDispatcher(new Agent().compose(interceptors.cache()));
});

=>

Application has thrown an uncaught exception and is terminated:
TypeError: interceptors.cache is not a function
    at file:///D:/frontend/server/chunks/_/nitro.mjs:8221:18
    at runNitroPlugins (file:///D:/XVRT/frontend/server/chunks/_/nitro.mjs:18122:7)
    at file:///D:/frontend/server/chunks/_/nitro.mjs:18133:1
    at ModuleJob.run (node:internal/modules/esm/module_job:439:25)
    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
    at async node:internal/modules/esm/loader:643:26

Workaround: add a package override to force undici v8 to be picked-up.

It seems a few PR have been done to cease bringing Undici through @nuxt/scripts, like #860 and #870. Is it possible to remove it entirely from @nuxt/scripts?

(I have tried a repro on Stackblitz, but I have been unable to repro on it or on a dev workstation.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    harlan-agent-wait-to-implementIssue triage found work that should wait before implementation.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions