Skip to content

node-expat cannot be imported in worker threadsΒ #203

@achille-roussel

Description

@achille-roussel

Hello,

I encountered an issue trying to load node-expat in the context of a worker thread, see the minimal reproduction below:

{
  "name": "node-expat-bug",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "node-expat": "^2.3.18"
  }
}
const { Worker, isMainThread } = require('worker_threads')

if (isMainThread) {
  // Require in the top-level context works fine.
  require('node-expat')
  worker = new Worker(__filename)
} else {
  // Require in the context of a worker thread throws an exception:
  //
  //    Error: Module did not self-register: ...
  //
  require('node-expat')
}

This may be an example of how to fix it schroffl/node-lzo#11

Does this module aim to be usable in the context of a worker threads?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions