Miniget not working?

I am trying to migrate some AWS Lambda functions to Cloudflare Worker but the below code seems to be not succeeding.

let body = await miniget(myJSfile, options.requestOptions).text();

What am I missing here? The same works fine at Lambda.

EDIT:
Tried this also but nothing:
let response = await fetch(myJSfile); body = await response.text();

miniget is a node module and properly imported via const miniget = require('miniget'); no error gets generated (like invalid function etc.) when using it, this should work as we are using webpack. The second example fetches a javascript file which is 1.1 MB in size, could that be an issue? Since, both miniget and fetch are not throwing any kind of error I guess the limitation is from Cloudflare infrastructure side? Are there any limits on how much we can fetch from remote servers?

The fetch works in the main index.js script but not when executed from another script which I am importing using const sig = require("./process.js"); ? This seems something CF specific, how to make this work?

Adding a few await instructions in front of logic function calls fixed the issue.

I’d suggest using something that don’t require wrapping Node API’s, something like this:

It’s also a lot smaller, but still do the same things.

1 Like