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

Cannot find fs/promises in Bruno scripting #2481

Open
2 tasks done
luccitan opened this issue Jun 18, 2024 · 3 comments
Open
2 tasks done

Cannot find fs/promises in Bruno scripting #2481

luccitan opened this issue Jun 18, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@luccitan
Copy link

I have checked the following:

  • I use the newest version of bruno.
  • I've searched existing issues and found nothing related to my issue.

Describe the bug

I am trying to write a pre-request script for my whole collection, and that script relies on puppeteer.

With this import :

try {
  const puppeteer = require('puppeteer');
} catch (error) {
  console.log(error.stack);
  throw error;
}

I get this as a response :

Error invoking remote method 'send-http-request': VMError: Cannot find module 'fs/promises'

I tried with multiple versions of puppeteer, but this does not seem relevant as fs/promises should be available for Node > 14, and current Bruno uses Node 16.16 if I'm not mistaken

.bru file to reproduce the bug

No response

Screenshots/Live demo link

Error logged from catching described above :

Capture d’écran 2024-06-18 à 15 47 09

Dump from console.log(process.versions) in my Bruno script :

Capture d’écran 2024-06-18 à 15 46 57

My Bruno package.json :

{
    "name": "<MY_PROJECT>",
    "version": "1.0.0",
    "main": "index.js",
    "dependencies": {
        "puppeteer": "^22.11.2"
    }
}
@luccitan luccitan added the bug Something isn't working label Jun 18, 2024
@bpoulaindev
Copy link
Contributor

Have you tried enable puppeteer in bruno.json by whitelisting it ?

@luccitan
Copy link
Author

Have you tried enable puppeteer in bruno.json by whitelisting it ?

I managed to go beyond this error by whitelisting bultin modules that failed to be loaded :

  "scripts": {
    "moduleWhitelist": [
      "fs/promises",
      "os",
      "child_process",
      "readline",
      "net",
      "tty",
      "tls",
      "crypto",
      "events"
    ],
    "filesystemAccess": {
      "allow": true
    }
  }

but now I have issues because process.stderr seems to be undefined under Electron

@bpoulaindev
Copy link
Contributor

I'm not sure you can access fs in the scripts, as those are exectued on client side (nextJs), not on the backend (Electron)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants