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

🐛 BUG: wrangler pages dev failing with error on Identifier '__cf_cjs' has already been declared #7572

Open
anywhichway opened this issue Dec 17, 2024 · 4 comments
Labels
bug Something that isn't working

Comments

@anywhichway
Copy link

Which Cloudflare product(s) does this pertain to?

Pages

What version(s) of the tool(s) are you using?

Wrangler 3.96.0

What version of Node are you using?

N/A

What operating system and version are you using?

Windows 11

Describe the Bug

Observed behavior

X [ERROR] service core:user:bitter-bread-d12c: Uncaught SyntaxError: Identifier '__cf_cjs' has already been declared

    at null.<anonymous> (fn7s4pcgxfq.js:1026)

Expected behavior

App starts

Steps to reproduce

Occurs when the code below is added as a function

Note: You will need to modify line 251 in json-bigint and comment out //case 'null': not valid because your linter also causes a fatal failure on this line

import { PromptRole } from "@llumiverse/core";
import { TogetherAIDriver } from "@llumiverse/drivers";
export async function onRequestPost(ctx) {
    const driver = new TogetherAIDriver({
        apiKey: "<some key>"
    });

    const prompt = [
        {
            role: PromptRole.user,
            content: 'Please, write a short story about winter in Paris, in no more than 512 characters.'
        }
    ]

    const body = await driver.execute(prompt, {
        model:"meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo",
        temperature: 0.6,
        max_tokens: 1024
    });
    return new Response(200,{body:JSON.stringify(body)})
    //return new Response(200,{body:JSON.stringify(prompt)});
}

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

wrangler-2024-12-17_15-58-15_864.log

@anywhichway anywhichway added the bug Something that isn't working label Dec 17, 2024
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Dec 17, 2024
@Webstablish
Copy link

Webstablish commented Dec 18, 2024

Having the same issue unfortunately.

Uncaught SyntaxError: Identifier '__cf_cjs' has already been declared

In my case it happens when I add a SDK to the project to make API calls to a third party. Commenting out the functions that use the SDK fixes the issue, but breaks the app.

Updating to the latest wrangler version didn't help.

@emily-shen
Copy link
Contributor

Hey thanks for the report! Can I check if you're all using nodejs_compat? And @Webstablish would be super helpful to know which SDK this is happening with.

@Webstablish
Copy link

@emily-shen, currently I have this in my wrangler.toml:
compatibility_flags = ["nodejs_compat_v2"]

The SDK I'm using is monday-sdk-js.

@anywhichway
Copy link
Author

anywhichway commented Dec 18, 2024 via email

@andyjessop andyjessop moved this from Untriaged to Backlog in workers-sdk Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working
Projects
Status: Backlog
Development

No branches or pull requests

3 participants