Skip to content

Error thrown for every image loaded #184

@lucor001

Description

@lucor001

I wanted to see if anyone else is seeing this issue. Images are being loaded correctly, and the module seems to work, but it throws an error into the log file for every image loaded.

Error:

0|MagicMirror  | [2026-01-30 08:33:33.602] [INFO]  [MMM-BackgroundSlideshow] Reading path "Pictures/LIAM AND BEYOUND/PXL_20221009_233002245.jpg" 
0|MagicMirror  | [2026-01-30 08:33:33.613] [WARN]  [MMM-BackgroundSlideshow] imageDir: Pictures/LIAM AND BEYOUND 
0|MagicMirror  | [2026-01-30 08:33:33.614] [WARN]  [MMM-BackgroundSlideshow] firesArray0: undefined 
0|MagicMirror  | [2026-01-30 08:33:33.616] [ERROR] [MMM-BackgroundSlideshow] Error reading directory  Pictures/LIAM AND BEYOUND : TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
0|MagicMirror  |     at Object.join (node:path:1354:7)
0|MagicMirror  |     at Class.getNextImage (/home/brendan/MagicMirror/modules/MMM-BackgroundSlideshow/node_helper.js:314:29)
0|MagicMirror  |     at Timeout._onTimeout (/home/brendan/MagicMirror/modules/MMM-BackgroundSlideshow/node_helper.js:478:12)
0|MagicMirror  |     at listOnTimeout (node:internal/timers:588:17)
0|MagicMirror  |     at process.processTimers (node:internal/timers:523:7) {
0|MagicMirror  |   code: 'ERR_INVALID_ARG_TYPE'
0|MagicMirror  | } 

Looking at node_helper.js around line 312 I found that the filesArray[0] is undefined. You can see that above where I added 2 warnings to essentially display imageDirectory and filesArray[0]. Strangely enough everything still seems to work correctly.
Code:

        filesArray = files.filter((file) => file.startsWith(baseFilename) && path.extname(file).toLowerCase() === `${imageFilenameEnumeratedEnd}.json`);
        // actually, there is only one file expected
        Log.warn('imageDir:', imageDirectory);
        Log.warn('firesArray0:', filesArray[0]);
        jsonFilePath = path.join(imageDirectory, filesArray[0]);
        Log.log('JSON:', jsonFilePath);
        const jsonData = fs.readFileSync(jsonFilePath, 'utf8');

I think my configuration is pretty standard. I put all the pictures in /home/user/MagicMirror/Pictures/ and I've tried many different forms of this path all with the same result.

                {
                  module: 'MMM-BackgroundSlideshow',
                  position: 'fullscreen_below',
                  config: {
                    imagePaths: ["Pictures"],
                    transitionImages: true,
                    randomizeImageOrder: true,
                    slideshowSpeed: 30000,
                    recursiveSubDirectories: true,
                    backgroundSize: "contain"
                  }
                },

Anyone have any thoughts? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions