Skip to content

Use the plugin file when reporting a plugin load error line - #6040

Merged
knolleary merged 1 commit into
node-red:mainfrom
shubhamrai9122-creator:fix-loadplugin-error-line
Nov 11, 2026
Merged

knolleary merged 1 commit into
node-red:mainfrom
shubhamrai9122-creator:fix-loadplugin-error-line

Conversation

@shubhamrai9122-creator

Copy link
Copy Markdown
Contributor
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Proposed changes

Fixes #6008.

loadPlugin()'s catch block used node.file, a line copied from loadNodeSet(), but the parameter there is plugin. When a plugin's file threw on require, the catch block itself threw ReferenceError: node is not defined. loadNodeSetList() swallowed that, so plugin.err stayed a raw Error (which serialises as {}) instead of becoming "<error> (line:N)" like it does for node sets.

The fix uses plugin.file. The new test in loader_spec.js loads a core plugin whose file throws on its first line and checks that plugin.err is "Error: fail to load plugin (line:1)". Without the fix, err is still the raw Error and the test fails.

Checklist

  • I have read the contribution guidelines
  • For non-bugfix PRs, I have discussed this change on the forum/slack team.
  • I have run npm run test to verify the unit tests pass (I ran the registry unit tests: npx mocha "test/unit/@node-red/registry/**/*_spec.js", 148 passing)
  • I have added suitable unit tests to cover the new/changed functionality

loadPlugin() referred to node.file, copied from loadNodeSet(), so a
plugin whose file threw on require hit a ReferenceError in its catch
block. The error was swallowed and plugin.err stayed a raw Error instead
of a message with the failing line.

Signed-off-by: shubhamrai9122-creator <[email protected]>
@knolleary
knolleary merged commit fc99dc7 into node-red:main Nov 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Broken plugin's error handler crashes with ReferenceError (node is not defined) - loadPlugin catch block references node.file

2 participants