Skip to content

Restarting the server for tests fails to register node type #5592

@tobias47n9e

Description

@tobias47n9e

Current Behavior

I have some custom tests written in Deno that start a Node-RED server. On the first startup everything works perfectly and I can install a custom node. But when the tests restart the server for the next suite, I get this error:

RED.init(server, {
  userDir: '/tmp/.node-red'
});
err: Error: Set has no types
      at Object.addModule (file:///var/.deno-cache/npm/registry.npmjs.org/@node-red/registry/4.1.5/lib/registry.js:227:29)
      at file:///var/.deno-cache/npm/registry.npmjs.org/@node-red/registry/4.1.5/lib/loader.js:145:30
      at async nodeRedServer (file:///var/src/test/_context/node-red-server.ts:36:3)
code: "set_has_no_types",
    details: {
      file: "/tmp/.node-red/node_modules/@vendor/package/node-v1/node-v1.js",

Expected Behavior

I would expect that I can restart the server and the existing nodes in the /tmp/.node-red continue to work.

When I made the following changes I could get it to work:

// registry.js
function emptyModuleConfigs() {
    moduleConfigs = {};
    moduleNodes = {};
}
// loader.js
function loadModuleFiles(modules) {
    registry.emptyModuleConfigs(); // Add this call here to start fresh before loading the modules
    // ....
}

Would it make sense to submit this as a patch or am I doing something wrong on my side?

Steps To Reproduce

No response

Example flow

Environment

  • Node-RED version: v4.1.5
  • Node.js version: v24.2.0
  • npm version: 11.9.0
  • Platform/OS: Deno in Docker container
  • Browser: -

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions