denoflare icon indicating copy to clipboard operation
denoflare copied to clipboard

Error running script SyntaxError: Identifier 'concat' has already been declared at blob:null/fc6d65b1-68e1-4492-9180-8f3271ba2cd7:824:1

Open supfiger opened this issue 1 year ago • 3 comments

In my Deno grammY application, when I call apiThrottler function from @grammyjs/transformer-throttler package, and run $ denoflare serve src/prod-cloudflare.ts, I've got the following error:

Error running script SyntaxError: Identifier 'concat' has already been declared at blob:null/fc6d65b1-68e1-4492-9180-8f3271ba2cd7:824:1
    at async Function.create (blob:null/f2d9e371-4eb3-4dc9-8976-db324eb14fef:563:24)
    at async Function.start (blob:null/f2d9e371-4eb3-4dc9-8976-db324eb14fef:679:50)
    at async blob:null/f2d9e371-4eb3-4dc9-8976-db324eb14fef:2781:22
    at async RpcChannel.receiveMessage (blob:null/f2d9e371-4eb3-4dc9-8976-db324eb14fef:39:36)
    at async self.onmessage (blob:null/f2d9e371-4eb3-4dc9-8976-db324eb14fef:2810:13)

Context:

  • denoflare: 0.5.11
  • deno: 1.34.3 (release, x86_64-apple-darwin)
  • v8: 11.5.150.2
  • typescript: 5.0.4
  • os: MacOS 13.2.1 (22D68)
  • @grammyjs/transformer-throttler: https://deno.land/x/[email protected]/mod.ts

But, on Node.js, and using it (@grammyjs/transformer-throttler) via NPM – it works OK (it means I don't get this error).

supfiger avatar Jun 24 '23 17:06 supfiger

Looks like an error in your bundle output (denoflare uses deno bundle under the hood).

Try running serve without local isolation:

$ denoflare serve <path> --local-isolation none

You'll lose hot reload, but it will try to import your bundle directly in the main process, perhaps allowing you to see the error.

Could also try running deno bundle on your script and look at the output for the duplicate concat it's complaining about

johnspurlock-skymethod avatar Jun 24 '23 18:06 johnspurlock-skymethod

About running with --local-isolation none:

$ denoflare serve src/prod-cloudflare.ts --local-isolation none

error: Uncaught (in promise) TypeError: Relative import path "src/prod-cloudflare.ts" not prefixed with / or ./ or ../
        const module = await import(scriptPath);

$ denoflare serve ./src/prod-cloudflare.ts --local-isolation none

error: Uncaught (in promise) TypeError: Module not found "https://raw.githubusercontent.com/skymethod/denoflare/v0.5.12/common/src/prod-cloudflare.ts".
        const module = await import(scriptPath);

$ denoflare serve /Users/supfiger/coding/apps/mine/deno-grammy/src/prod-cloudflare.ts --local-isolation none

error: Uncaught (in promise) TypeError: Module not found "https://raw.githubusercontent.com/Users/supfiger/coding/apps/mine/deno-grammy/src/prod-cloudflare.ts".
        const module = await import(scriptPath);

Looks like if I provide absolute path to file, it tries to get it not from skymethod repo, but from the provided path, but it's an invalid path (and even more – my repo is private).


I also ran deno bundle src/prod-cloudflare.ts and haven’t got any error.

supfiger avatar Jun 24 '23 19:06 supfiger

Do you have bare imports in your script? Denoflare supports ./ and https://... old school Deno imports, nothing that requires import map config or npm deps etc.

johnspurlock-skymethod avatar Jun 24 '23 22:06 johnspurlock-skymethod