Repository navigation
[BUG] User Scripts are Running & Throwing Error #2208
Description
Describe the bug
To be transparent, this might just be an error with my scripting, but I encountered an error running a long-time script via User Scripts in QuickAdd recently.
Basically, while the script runs successfully, it throws an error. This has not happened historically, I believe since I last used it a month ago.
This error persists across restarts of Obsidian, and with the latest version of Obsidian / its installer / QuickAdd.
To Reproduce
- I have a file
Obsidian Notes > User Scripts > create_wp_folder.jswhich has the following script:
const fs = require('fs');
const path = require('path');
const targetFolderPath = 'Novel Writing/Writing Prompts/' + moment().format('YYYY') + '/' + moment().format('MM MMM');
// Ensure the target folder exists
const absoluteTargetFolderPath = path.join(app.vault.adapter.basePath, targetFolderPath);
if (!fs.existsSync(absoluteTargetFolderPath)) {
fs.mkdirSync(absoluteTargetFolderPath, { recursive: true });
}-
I created a macro with the script.
-
The error below (in Console Logs) is outputted, even though the script executes successfully.
Expected behavior
No error to be thrown.
Obsidian Debug Info (required for bug reports)
SYSTEM INFO:
Obsidian version: 1.14.4
Installer version: 1.14.4
Operating system: Windows 11 Home 10.0.26200
Login status: logged in
Language: en
Catalyst license: none
Insider build toggle: off
Live preview: on
Base theme: adapt to system
Community theme: Minimal 9.0.2
Snippets enabled: 18
Restricted mode: off
Plugins installed: 42
Plugins enabled: 36
1: Iconize v2.14.7
2: Iconic v1.1.10
3: Lazy Loader v1.0.24
4: Tasks v8.4.0
5: Dice Roller v11.4.2
6: Templater v2.25.1
7: Quiet Outline v0.5.20
8: TaskNotes v4.13.8
9: Datacore v0.1.29
10: Dataview v0.5.68
11: Advanced Exclude v4.1.3
12: List Callouts Improved v1.8.1
13: Homepage v4.5.0
14: Minimal Theme Settings v9.0.0
15: Style Settings v1.0.9
16: Word-Smith v1.8.1
17: Cornell Notes v1.0.4
18: Editing Toolbar v4.1.9
19: Image Captions v1.2.1
20: Meta Bind v1.5.1
21: Outliner v4.10.2
22: QuickAdd v2.32.0
23: Text Format v3.1.0
24: Colored Tags v7.0.1
25: Fantasy Statblocks v4.10.3
26: Folder Note v0.7.3
27: Git v2.41.1
28: Image Converter v1.4.6
29: JS Engine v0.3.6
30: Latex Suite v1.13.4
31: Linter v1.33.0
32: Natural Language Dates v0.6.4
33: Omnisearch v1.31.0
34: Spaced Repetition v1.15.4
35: User Plugins v1.4.0
36: Waypoint v3.0.1
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
- Obsidian version: 1.14.4
- QuickAdd version: 2.32.0
- Operating system: Windows 11 Home 10.0.26200
- Debug info: Paste output from Developer Tools (Ctrl+Shift+I or Cmd+Option+I on Mac)
- Other plugins enabled: [List any other plugins that might be relevant]
- Theme: Minimal
Console Logs
plugin:quickadd:360 QuickAdd: (ERROR) Failed to run user script create_wp_folder in "Macro - Create Writing Prompt": user script in macro for 'Macro - Create Writing Prompt' is an empty object Error: Failed to run user script create_wp_folder in "Macro - Create Writing Prompt": user script in macro for 'Macro - Create Writing Prompt' is an empty object
at h (plugin:quickadd:120:5327)
at QW (plugin:quickadd:120:6286)
at async ta.executeUserScript (plugin:quickadd:120:16191)
at async eval (plugin:quickadd:120:15172)
at async ta.executeCommands (plugin:quickadd:120:15044)
at async ta.run (plugin:quickadd:120:14312)
at async Ar.onChooseMacroType (plugin:quickadd:371:19866)
at async eval (plugin:quickadd:371:16360)
at async Ar.execute (plugin:quickadd:371:16129)
at async ok.runRegisteredChoice (plugin:quickadd:390:30833)
logError @ plugin:quickadd:360
Activity
test(macro): cover a user script that exports nothing (#2208)
fix(macro): let a user script that exports nothing finish its macro (#…
fix(macro): let a user script that exports nothing finish its macro (#…
chhoumann commentedon Oct 9, 2026
Hey @RumiaKitinari! Thanks for the report, and for including the full script. That made it easy to reproduce. I could reproduce it, and it's fixed in #2209, which will ship in the next QuickAdd release.
Your script does all its work at the top level and doesn't export anything. QuickAdd runs that code when it loads the script, so the folder was created. Then it looked for an exported function to call, found nothing, and treated that as an error. That error also stopped the macro, so if you had added steps after the script, they wouldn't have run. Now a script that exports nothing counts as finished, and the macro moves on.
I tested it in Obsidian with your script, followed by a second script in the same macro. Before the fix, the folder was created, the error showed, and the second step never ran. After the fix, the folder is created, the second step runs, and there's no error.
Until the release is out, you can avoid the error by wrapping your code in an exported function:
Let me know if anything still acts up after you update!