Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nodesDir scan when node package has js/html in sub dir to package.json #3867

Merged
merged 4 commits into from
Nov 30, 2022

Conversation

Steve-Mcl
Copy link
Contributor

@Steve-Mcl Steve-Mcl commented Sep 3, 2022

fixes #3861

Types of changes

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

First, please read through the issue detailed in this comment

Proposed changes

  • Normalise path before splitting (loader.js)

  • Skip calling statSync on empty string (loader.js)

  • Shortcut scanning of a directories files/folders if the directory contains a package.json (localfilesystem.js)

  • Prevent crashing node-red when set.types is not set (registry.js)

  • Print out which node caused the error

    • BEFORE:
    TypeError: Cannot read properties of undefined (reading 'forEach')
    at Object.addModule (/usr/lib/node_modules/node-red/node_modules/@node-red/registry/lib/registry.js:195:27)
    at /usr/lib/node_modules/node-red/node_modules/@node-red/registry/lib/loader.js:153:34
    
    • AFTER: (Updated 2022/09/29, after commit e6b3793)
    29 Sep 21:25:17 - [warn] [node-red/lower-case] Set does not have any types. name: 'lower-case', module: 'node-red', file: 'C:\Users\user\repos\_node-red-issue-3861\lower-case.js'
    packages/node_modules/@node-red/util/lib/log.js:94
    29 Sep 21:25:31 - [warn] [node-red-node-google/google-api-config] 'google-api-config' already registered by module node-red-contrib-google-calendar
    packages/node_modules/@node-red/util/lib/log.js:94
    29 Sep 21:25:31 - [warn] [node-red-node-rbe/rbe] 'rbe' already registered by module node-red
    packages/node_modules/@node-red/util/lib/log.js:94
    29 Sep 21:25:31 - [warn] [@flowforge/nr-project-nodes/project-link] Error: Project Link nodes cannot be loaded outside of flowforge EE environment
    packages/node_modules/@node-red/util/lib/log.js:94
    29 Sep 21:25:57 - [warn] [lower-case/lower-case] Set does not have any types. name: 'lower-case', module: 'lower-case', file: 'C:\Users\user\repos\_node-red-issue-3861\lower-case\lower-case\lower-case.js'
    packages/node_modules/@node-red/util/lib/log.js:94
    29 Sep 21:26:06 - [warn] [@lowercase/lower-case2/lower-case] Set does not have any types. name: 'lower-case', module: '@lowercase/lower-case2', file: 'C:\Users\user\repos\_node-red-issue-3861\@lower-case\lower-case2\lower-case.js'
    
  • Add more tests that load nodes with js/html files in a sub directory (registry.js)

Checklist

  • I have read the contribution guidelines
  • For non-bugfix PRs, I have discussed this change on the forum/slack team.
  • I have run grunt to verify the unit tests pass
  • I have added suitable unit tests to cover the new/changed functionality

@coveralls
Copy link

coveralls commented Sep 3, 2022

Coverage Status

Coverage decreased (-0.04%) to 68.306% when pulling 6d1a12a on Steve-Mcl:improve-nodesdir-scan into a5d7f7a on node-red:master.

Copy link
Member

@knolleary knolleary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your before/after shows the log output in the before, but a screenshot of the error object inside VSCode for the after.
End-users won't be running in VSCode - what actually gets logged? Does it include the extra information about what module caused it?

packages/node_modules/@node-red/registry/lib/registry.js Outdated Show resolved Hide resolved
@knolleary knolleary added this to the 3.1 milestone Nov 7, 2022
@knolleary knolleary merged commit 02af01d into node-red:master Nov 30, 2022
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.

nodesDir crashes Node-RED 3.0
3 participants