Search code examples
node.jswindows-runtimeelectronstoragefile

NodeRT - StorageFile.openAsync returns undefined fileStream, but no error


I'm just getting started with NodeRT & Electron (Windows 10). Some of the basics seem to be working, but I've quickly run up against a strange issue. Here's the code:

const {FileAccessMode, StorageFile} = require('electron').remote.require('@nodert-win10/windows.storage')

var fname = require('electron').remote.app.getPath('userData') + '\\test.jpg';

StorageFile.getFileFromPathAsync(fname, (err, storageFile) => {
    if (err) return console.log(err);

    storageFile.openAsync(FileAccessMode.read, (err, fileStream) => {
        if (err) return console.log(err);

        // fileStream is NULL HERE!
    })
})

getFileFromPathAsync succeeds and the resulting storageFile is valid. However, openAsync returns an undefined fileStream and an undefined err!

Questions:

  • What am I doing wrong here?

  • In any case, why is openAsync failing silently with no error?

Thanks!


Solution

  • Finally, this was a bug in NodeRT when used in combo with the most recent electron builds. It is now fixed.

    Props to @nadavbar for fixing this the same day that I reported it. :) NodeRT seems to play very nicely with electron now.