zazuko / cube-link

Cube Schema
https://zazuko.github.io/cube-link/
Other
12 stars 8 forks source link

The Trifid instance is crashing since it was converted to ESM #169

Closed ludovicm67 closed 5 months ago

ludovicm67 commented 5 months ago

I saw that the instance was not starting, health checks are failing. No special logs.

I tried to run it locally using:

npm i
DEBUG=* npm run trifid:local

And I was able to see the following error:

  trifid: Error [ERR_REQUIRE_ESM]: require() of ES Module ***/cube-link/trifid/redirect.js from ***/cube-link/node_modules/trifid-core/lib/module-loader.js not supported.
  trifid: redirect.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
  trifid: Instead either rename redirect.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in ***/cube-link/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
  trifid:
  trifid:     at Object.customRequire [as require] (***/cube-link/node_modules/trifid-core/lib/module-loader.js:12:10)
  trifid:     at ***/cube-link/node_modules/trifid-core/plugins/middleware.js:5:39
  trifid:     at ***/cube-link/node_modules/trifid-core/lib/middleware.js:8:12
  trifid:     at tryCatcher (***/cube-link/node_modules/bluebird/js/release/util.js:16:23)
  trifid:     at Promise._settlePromiseFromHandler (***/cube-link/node_modules/bluebird/js/release/promise.js:547:31)
  trifid:     at Promise._settlePromise (***/cube-link/node_modules/bluebird/js/release/promise.js:604:18)
  trifid:     at Promise._settlePromiseCtx (***/cube-link/node_modules/bluebird/js/release/promise.js:641:10)
  trifid:     at _drainQueueStep (***/cube-link/node_modules/bluebird/js/release/async.js:97:12)
  trifid:     at _drainQueue (***/cube-link/node_modules/bluebird/js/release/async.js:86:9)
  trifid:     at Async._drainQueues (***/cube-link/node_modules/bluebird/js/release/async.js:102:5)
  trifid:     at Async.drainQueues [as _onImmediate] (***/cube-link/node_modules/bluebird/js/release/async.js:15:14) +10ms

It looks like the commit 8d7e34986a37a922908b693c90959ff1b6785bc4 introduced this issue.

I will provide a fix for it.