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

path.join throw error in Service Worker #291

Open
jcubic opened this issue May 3, 2020 · 16 comments
Open

path.join throw error in Service Worker #291

jcubic opened this issue May 3, 2020 · 16 comments
Labels

Comments

@jcubic
Copy link

jcubic commented May 3, 2020

If you call this path.join('/'. 'file') in service worker it throw exception:

Error: ENOENT: No such file or directory., '/'
Error
    at new ApiError (https://cdn.jsdelivr.net/npm/[email protected]/dist/browserfs.js:5430:22)
    at Function.FileError (https://cdn.jsdelivr.net/npm/[email protected]/dist/browserfs.js:5455:16)
    at Function.ENOENT (https://cdn.jsdelivr.net/npm/[email protected]/dist/browserfs.js:5458:21)
    at https://cdn.jsdelivr.net/npm/[email protected]/dist/browserfs.js:13987:37
    at IDBRequest. (https://cdn.jsdelivr.net/npm/[email protected]/dist/browserfs.js:14270:17)

it work outside of worker.

@james-pre
Copy link
Collaborator

@jcubic Please try with the latest commit. If it still does not work, a PR would be greatly appreciated!

@james-pre james-pre added the bug label Mar 9, 2023
@jcubic
Copy link
Author

jcubic commented Mar 10, 2023

Will check, is the latest version published to NPM?

@james-pre
Copy link
Collaborator

@jcubic I don't believe so. You will need to clone the repo and build from source.

@jcubic
Copy link
Author

jcubic commented Mar 10, 2023

ok, will see if I will be able to test tomorrow. I'm on a trip but got a laptop with me.

@jcubic
Copy link
Author

jcubic commented Mar 11, 2023

I'm not able to build the project got error from NodeJS:

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (/home/kuba/projects/jcubic/BrowserFS/node_modules/webpack/lib/util/createHash.js:90:53)
    at NormalModule._initBuildHash (/home/kuba/projects/jcubic/BrowserFS/node_modules/webpack/lib/NormalModule.js:386:16)
    at handleParseError (/home/kuba/projects/jcubic/BrowserFS/node_modules/webpack/lib/NormalModule.js:434:10)
    at /home/kuba/projects/jcubic/BrowserFS/node_modules/webpack/lib/NormalModule.js:466:5
    at /home/kuba/projects/jcubic/BrowserFS/node_modules/webpack/lib/NormalModule.js:327:12
    at /home/kuba/projects/jcubic/BrowserFS/node_modules/loader-runner/lib/LoaderRunner.js:370:3
    at iterateNormalLoaders (/home/kuba/projects/jcubic/BrowserFS/node_modules/loader-runner/lib/LoaderRunner.js:211:10)
    at iterateNormalLoaders (/home/kuba/projects/jcubic/BrowserFS/node_modules/loader-runner/lib/LoaderRunner.js:218:10)
    at /home/kuba/projects/jcubic/BrowserFS/node_modules/loader-runner/lib/LoaderRunner.js:233:3
    at context.callback (/home/kuba/projects/jcubic/BrowserFS/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at processMap (/home/kuba/projects/jcubic/BrowserFS/node_modules/source-map-loader/index.js:103:3)
    at /home/kuba/projects/jcubic/BrowserFS/node_modules/source-map-loader/index.js:53:6
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

This seems to be a common NodeJS error but I'm not able to solve it by adding:

export NODE_TLS_REJECT_UNAUTHORIZED=0

@james-pre
Copy link
Collaborator

Interesting... I don't believe that error is related to BrowserFS so it is most likely with your machine.

@jcubic
Copy link
Author

jcubic commented Mar 12, 2023 via email

@james-pre
Copy link
Collaborator

@jcubic Have you tried this Stack Overflow answer? It should prevent the SSL error.

@jcubic
Copy link
Author

jcubic commented Mar 23, 2023

@james-pre thanks it works, I think that I've missed this. But I think that all those errors are problems with the library that doesn't support the latest NodeJS. I have the same with a project I'm maintaining and this is my project's fault that this throws an error and requires disabling security hacks to work.

@james-pre
Copy link
Collaborator

@jcubic I'm working on updating all of BrowserFS' various dependencies so it should get fixed soon.

@jcubic
Copy link
Author

jcubic commented Mar 23, 2023

I've added browserFS build file to my project that uses service worker and I've got a different error:

Error: ENOENT: No such file or directory., '/'

from fs.stat('/test/index.html').

The whole code was working fine. This my setup:

self.addEventListener('fetch', function (event) {
    let path = BrowserFS.BFSRequire('path');
    let fs = new Promise(function(resolve, reject) {
        BrowserFS.configure({ fs: 'IndexedDB', options: {} }, function (err) {
            if (err) {
                reject(err);
            } else {
                resolve(BrowserFS.BFSRequire('fs'));
            }
        });
    });
    event.respondWith(fs.then(function(fs) {
        // ...
    });
});

I'm not sure if the API changed. If I changed the app to also use new BrowserFS that app stops working and throws an error on ls command on the root directory.

What are the breaking changes in 2.0?

@james-pre
Copy link
Collaborator

@jcubic

configureAsync (source code) should simplify the code your using. In addition, you no longer need to supply options for IndexedDB (see #352).

As for the error, I'm not entirely sure why it is being thrown. I would suggest you change the code to use configureAsync and change the event listener to use async/await and await the configureAsync call.

I will look into the error more in the mean time (and hopefully fix the ApiError stack)

@james-pre
Copy link
Collaborator

james-pre commented Mar 29, 2023

@jcubic I just fixed the issues causing the errors above in #355. You should be able to run BFS normally again.

Specifically, this commit fixed multiple errors (see the commit notes)

@jcubic
Copy link
Author

jcubic commented Mar 29, 2023

Thanks, Will check my app with the latest version.

@jcubic
Copy link
Author

jcubic commented Mar 30, 2023

The ls command works but when I want to clone the repo. Got an error from this function:

AsyncKeyValueFileSystem.prototype.getDirListing = function getDirListing (tx, p, inode, cb) {
  if (!inode.isDirectory()) {
	cb(ApiError.ENOTDIR(p));
  }
  else {
	tx.get(inode.id, function (e, data) {
	  if (noError(e, cb)) {
	    try {
	      cb(null, JSON.parse(data.toString()));
	    }
	    catch (e) {
	      // Occurs when data is undefined, or corresponds to something other
	      // than a directory listing. The latter should never occur unless
	      // the file system is corrupted.
	      cb(ApiError.ENOENT(p));
	    }
	  }
	});
  }
};

data is undefined.

Also, I needed to delete the old database because it was not compatible and was throwing errors.

@james-pre
Copy link
Collaborator

Closing (stale). If you would like to reopen this issue, please do so by creating a new issue in the relevant repositories of @browser-fs

@james-pre james-pre closed this as not planned Won't fix, can't repro, duplicate, stale Oct 25, 2023
Repository owner locked and limited conversation to collaborators Oct 25, 2023
@james-pre james-pre reopened this May 17, 2024
Repository owner unlocked this conversation May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants