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

Compatibility issue with Cloudflare Worker #569

Open
lpellegr opened this issue Mar 30, 2024 · 1 comment
Open

Compatibility issue with Cloudflare Worker #569

lpellegr opened this issue Mar 30, 2024 · 1 comment

Comments

@lpellegr
Copy link

Using ky 1.2.3 as follows in a Cloudflare Worker instance:

try {
    const response = await ky.post('https://api.ipregistry.co/?key=tryout', {
        json: ["AS1", "AS6", "AS42"],
        headers: {
            "Content-Type": "application/json"
        }
    }).json();

    console.log(response);
} catch (error) {
    console.error(error);
}

produces the following ouput and errors upon execution in a Cloudflare Worker runtime:

✘ [ERROR] Your worker created multiple branches of a single stream (for instance, by calling response.clone() or request.clone()) but did not read the body of both branches. This is wasteful, as it forces the system to buffer the entire stream of data in memory, rather than streaming it through. This may cause your worker to be unexpectedly terminated for going over the memory limit. If you only meant to copy the request or response headers and metadata (e.g. in order to be able to modify them), use the appropriate constructors instead (for instance, new Response(response.body, response), new Request(request), etc).

{
results: [
{
allocated: '2001-09-20T00:00:00.000+00:00',
asn: 1,
country_code: 'US',
domain: 'level3.com',
name: 'Level 3 Parent, LLC',
prefixes: [Object],
relationships: [Object],
registry: 'ARIN',
type: 'business',
updated: '2024-02-28T00:00:00.000+00:00'
},
{
allocated: '1984-02-02T00:00:00.000+00:00',
asn: 6,
country_code: 'US',
domain: 'atos.net',
name: 'Atos IT Solutions And Services, Inc.',
prefixes: [Object],
relationships: [Object],
registry: 'ARIN',
type: 'business',
updated: '2021-01-21T00:00:00.000+00:00'
},
{
allocated: '2001-05-16T00:00:00.000+00:00',
asn: 42,
country_code: 'US',
domain: 'pch.net',
name: 'Woodynet, Inc.',
prefixes: [Object],
relationships: [Object],
registry: 'ARIN',
type: 'business',
updated: '2012-03-02T00:00:00.000+00:00'
}
]
}
✘ [ERROR] Your worker created multiple branches of a single stream (for instance, by calling response.clone() or request.clone()) but did not read the body of both branches. This is wasteful, as it forces the system to buffer the entire stream of data in memory, rather than streaming it through. This may cause your worker to be unexpectedly terminated for going over the memory limit. If you only meant to copy the request or response headers and metadata (e.g. in order to be able to modify them), use the appropriate constructors instead (for instance, new Response(response.body, response), new Request(request), etc).

✘ [ERROR] Your worker created multiple branches of a single stream (for instance, by calling response.clone() or request.clone()) but did not read the body of both branches. This is wasteful, as it forces the system to buffer the entire stream of data in memory, rather than streaming it through. This may cause your worker to be unexpectedly terminated for going over the memory limit. If you only meant to copy the request or response headers and metadata (e.g. in order to be able to modify them), use the appropriate constructors instead (for instance, new Response(response.body, response), new Request(request), etc).

I have no idea about how to work around this. Any idea?

@riderx
Copy link
Contributor

riderx commented May 2, 2024

did you added this in wrangler config
compatibility_flags = ["nodejs_compat"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants