Skip to content

V7 unexpected sqlite error when using PM2 #3899

@xconverge

Description

@xconverge

Bug Description

I am using pm2 for managing my application and something about the expermental node:sqlite detection doesn't work correctly/is incompatible.

Reproducible By

test.js:

const { fetch } = require("undici");
console.log("hello");

This works fine of course:

node test.js

This does not:

pm2 start test.js

and errors with this

pm2 logs
Error: Cannot find module 'node:sqlite'
Require stack:
- /path/src/archive/test/node_modules/undici/lib/cache/sqlite-cache-store.js
- /path/src/archive/test/node_modules/undici/index.js
- /path/src/archive/test/test.js
    at Function._resolveFilename (node:internal/modules/cjs/loader:1249:15)
    at Hook._require.Module.require (/path/.local/share/nvm/v22.11.0/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:81:25)
    at require (node:internal/modules/helpers:141:16)
    at Object.<anonymous> (/path/src/archive/test/node_modules/undici/lib/cache/sqlite-cache-store.js:3:26)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Object..js (node:internal/modules/cjs/loader:1689:10)
    at Module.load (node:internal/modules/cjs/loader:1318:32)
    at Function._load (node:internal/modules/cjs/loader:1128:12)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:218:24) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/path/src/archive/test/node_modules/undici/lib/cache/sqlite-cache-store.js',
    '/path/src/archive/test/node_modules/undici/index.js',
    '/path/src/archive/test/test.js'
  ]
}

I can get around it by explicitly setting the flag like this

pm2 start test.js --node-args="--experimental-sqlite"

Expected Behavior

node:sqlite is detected correctly (as missing or not) when running through pm2

Logs & Screenshots

Environment

Node v22
Undici v7.0.0

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions