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

n8n crashes on start if LocalFileTrigger option ignored is an empty string #4824

Closed
marzn opened this issue Dec 5, 2022 · 2 comments · Fixed by #4825
Closed

n8n crashes on start if LocalFileTrigger option ignored is an empty string #4824

marzn opened this issue Dec 5, 2022 · 2 comments · Fixed by #4825

Comments

@marzn
Copy link
Contributor

marzn commented Dec 5, 2022

Describe the bug

If a LocalFileTrigger is configured with the ignore option but no input (default is an empty string) or the input is deleted, but the ignore option is not deleted, this will result in a crash of n8n. n8n is even not able to restart, because the LocalFileTrigger is executed on startup.

Log / Stacktrace:

/usr/local/lib/node_modules/n8n/node_modules/picomatch/lib/picomatch.js:48
    throw new TypeError('Expected pattern to be a non-empty string');
          ^

TypeError: Expected pattern to be a non-empty string
    at picomatch (/usr/local/lib/node_modules/n8n/node_modules/picomatch/lib/picomatch.js:48:11)
    at createPattern (/usr/local/lib/node_modules/n8n/node_modules/anymatch/index.js:27:18)
    at /usr/local/lib/node_modules/n8n/node_modules/anymatch/index.js:91:21
    at Array.map (<anonymous>)
    at anymatch (/usr/local/lib/node_modules/n8n/node_modules/anymatch/index.js:91:6)
    at FSWatcher._isIgnored (/usr/local/lib/node_modules/n8n/node_modules/chokidar/index.js:776:25)
    at NodeFsHandler._addToNodeFs (/usr/local/lib/node_modules/n8n/node_modules/chokidar/lib/nodefs-handler.js:581:16)
    at /usr/local/lib/node_modules/n8n/node_modules/chokidar/index.js:451:47
    at Array.map (<anonymous>)
    at FSWatcher.add (/usr/local/lib/node_modules/n8n/node_modules/chokidar/index.js:450:13)
    at watch (/usr/local/lib/node_modules/n8n/node_modules/chokidar/index.js:969:11)
    at Object.trigger (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/LocalFileTrigger/LocalFileTrigger.node.js:179:46)
    at Workflow.runTrigger (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:570:33)
    at ActiveWorkflows.add (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/ActiveWorkflows.js:26:50)
    at async ActiveWorkflowRunner.add (/usr/local/lib/node_modules/n8n/dist/ActiveWorkflowRunner.js:475:17)
    at async ActiveWorkflowRunner.init (/usr/local/lib/node_modules/n8n/dist/ActiveWorkflowRunner.js:72:21)
    at async /usr/local/lib/node_modules/n8n/dist/commands/start.js:274:17
    at async Start.run (/usr/local/lib/node_modules/n8n/dist/commands/start.js:116:9)
    at async Start._run (/usr/local/lib/node_modules/n8n/node_modules/@oclif/command/lib/command.js:43:20)
    at async Config.runCommand (/usr/local/lib/node_modules/n8n/node_modules/@oclif/config/lib/config.js:173:24)
    at async Main.run (/usr/local/lib/node_modules/n8n/node_modules/@oclif/command/lib/main.js:28:9)
    at async Main._run (/usr/local/lib/node_modules/n8n/node_modules/@oclif/command/lib/command.js:43:20)

To Reproduce
Steps to reproduce the behavior:

  1. Add 'LocalFileTrigger' node
  2. Select 'Trigger On' -> 'Changes to s Specific File'
  3. Insert some path for 'File to Watch', non existing files are valid, so you may insert something like '/tmp/tmp.txt'
  4. Click 'Add Option'
  5. Click 'Ignore'
  6. Save workflow
  7. Activate workflow

Expected behavior

n8n should not crash (on startup).

Environment (please complete the following information):

  • OS: [Ubuntu 20.04.5]
  • n8n Version [master (915f144)]
  • Node.js Version [v18.12.1]
  • Database system [SQLite]
  • Operation mode [own?]

Additional context

@Joffcom
Copy link
Member

Joffcom commented Dec 6, 2022

Hey @marzn,

Thanks for the report and the work you have done putting in the PR to fix this one, I have given it a test and with your fix it is working as it should. Nice work 🙌🏻

Joffcom pushed a commit that referenced this issue Dec 6, 2022
@Joffcom Joffcom added the Upcoming Release Will be part of the upcoming release label Dec 6, 2022
MiloradFilipovic added a commit that referenced this issue Dec 6, 2022
* master:
  fix: Handle error when workflow does not exist or is inaccessible (#4831)
  feat(editor): Schema view (#4615)
  fix: Enable source-maps on WorkflowRunnerProcess in `own` mode (#4832)
  ci: Fix linting on master (no-changelog) (#4830)
  feat: Add message for readonly nodes. Improve foreign credentials handling (#4759)
  feat(KoBoToolbox Node): Add support for Media file API (#4578)
  fix(Local File Trigger Node): Fix issue that causes a crash if the ignore field is empty (#4824) (#4825)
  refactor: Codex updates for XML and HtmlExtract Nodes (#4801)
  refactor: Reactivate workflow locking (#4770)

# Conflicts:
#	packages/editor-ui/src/Interface.ts
@janober
Copy link
Member

janober commented Dec 7, 2022

Fix got released with n8n@0.206.1

@janober janober removed the Upcoming Release Will be part of the upcoming release label Dec 7, 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
3 participants