invalid url string when attempting js module import

Currently trying to import from a file...
import {metadataExtractor} from './extractor/extractor.js'
import {metadataExtractor} from './extractor/extractor.js'
I get this error when I try to hit my worker
text: 'A request to the Cloudflare API
(/accounts/61d49c021d802c88abdb553e6f9342dd/workers/scripts/dark-voice-8281/edge-preview)
failed.',
notes: [
{
text: 'Uncaught TypeError: Invalid URL string.\n' +
' at index.js:1453:32\n' +
' at index.js:1550:3\n' +
' [code: 10021]'
}
],
location: undefined,
kind: 'error',
code: 10021
}
text: 'A request to the Cloudflare API
(/accounts/61d49c021d802c88abdb553e6f9342dd/workers/scripts/dark-voice-8281/edge-preview)
failed.',
notes: [
{
text: 'Uncaught TypeError: Invalid URL string.\n' +
' at index.js:1453:32\n' +
' at index.js:1550:3\n' +
' [code: 10021]'
}
],
location: undefined,
kind: 'error',
code: 10021
}
17 Replies
danny.m
danny.m8mo ago
No description
danny.m
danny.m8mo ago
The file path should be correct I guess this is also part of the error
Total Upload: 40.52 KiB / gzip: 8.05 KiB
✘ [ERROR] Error on remote worker: ParseError: A request to the Cloudflare API (/accounts/61d49c021d802c88abdb553e6f9342dd/workers/scripts/dark-voice-8281/edge-preview) failed.

at throwFetchError
(/Users/interpretations/projects/extraction/dark-voice-8281/node_modules/wrangler/wrangler-dist/cli.js:121307:17)
at fetchResult
(/Users/interpretations/projects/extraction/dark-voice-8281/node_modules/wrangler/wrangler-dist/cli.js:121259:5)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async createPreviewToken
(/Users/interpretations/projects/extraction/dark-voice-8281/node_modules/wrangler/wrangler-dist/cli.js:150628:29)
at async createWorkerPreview
(/Users/interpretations/projects/extraction/dark-voice-8281/node_modules/wrangler/wrangler-dist/cli.js:150649:17)
at async start
(/Users/interpretations/projects/extraction/dark-voice-8281/node_modules/wrangler/wrangler-dist/cli.js:150855:34)
{
Total Upload: 40.52 KiB / gzip: 8.05 KiB
✘ [ERROR] Error on remote worker: ParseError: A request to the Cloudflare API (/accounts/61d49c021d802c88abdb553e6f9342dd/workers/scripts/dark-voice-8281/edge-preview) failed.

at throwFetchError
(/Users/interpretations/projects/extraction/dark-voice-8281/node_modules/wrangler/wrangler-dist/cli.js:121307:17)
at fetchResult
(/Users/interpretations/projects/extraction/dark-voice-8281/node_modules/wrangler/wrangler-dist/cli.js:121259:5)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async createPreviewToken
(/Users/interpretations/projects/extraction/dark-voice-8281/node_modules/wrangler/wrangler-dist/cli.js:150628:29)
at async createWorkerPreview
(/Users/interpretations/projects/extraction/dark-voice-8281/node_modules/wrangler/wrangler-dist/cli.js:150649:17)
at async start
(/Users/interpretations/projects/extraction/dark-voice-8281/node_modules/wrangler/wrangler-dist/cli.js:150855:34)
{
Hello, I’m Allie!
Looks like something inside either extractor or index.js is trying to parse an invalid URL string?
danny.m
danny.m8mo ago
maybe it's this?
const module0 = fetchCompile(new URL('./extractor.core.wasm', import.meta.url));
const module1 = fetchCompile(new URL('./extractor.core2.wasm', import.meta.url));
const module0 = fetchCompile(new URL('./extractor.core.wasm', import.meta.url));
const module1 = fetchCompile(new URL('./extractor.core2.wasm', import.meta.url));
Hello, I’m Allie!
Maybe? The structure above looks like some kind of OtherLang-to-WASM+Glue Code compiler, so might want to take it up there if there is an issue
danny.m
danny.m8mo ago
it is... it just works when i use it outside of cloudflare... wondering if cloudflare doesn't support import.meta https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta
import.meta - JavaScript | MDN
The import.meta meta-property exposes context-specific metadata to a JavaScript module. It contains information about the module, such as the module's URL.
Hello, I’m Allie!
I'm not sure, maybe try console.loging it to see?
danny.m
danny.m8mo ago
yeah... gave it a shot but it I think it chokes first
Hello, I’m Allie!
Looks like that is a no
danny.m
danny.m8mo ago
Think I figured it out, and I need to import my wasm directly... currently hitting this though
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".wasm" for /Users/interpretations/projects/extraction/dark-voice-8281/src/extractor/extractor.core.wasm
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".wasm" for /Users/interpretations/projects/extraction/dark-voice-8281/src/extractor/extractor.core.wasm
import one from "./extractor.core.wasm"
kian
kian8mo ago
Is this being tested with Wrangler?
danny.m
danny.m8mo ago
yes
kian
kian8mo ago
I can't reproduce it personally, with import module from "./square.wasm" and wrangler dev
danny.m
danny.m8mo ago
and then you pass module to WebAssembly.instantiate?
kian
kian8mo ago
That or instance, both should work. Workers doesn't support WASM from buffers, only modules, so they do the same thing. Passing a buffer to instantiate in Workers will result in an exception.
alina 🌸
alina 🌸2mo ago
fun, this one is still not fixed, half a year later
alina 🌸
alina 🌸2mo ago
ok this seems to be merged 4 hours ago https://github.com/cloudflare/workerd/pull/1553 fun timing
GitHub
Initial implementation of new jsg module registry by jasnell · Pull...
RM-17318 First step of the new module registry implementation (the jsg only bits). Expect several more follow up PRs. This PR provides the initial core of the new module registry implementation. It...