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] response.buffer and response.json do not resolve nor rejects #166

Open
1 task done
MaurizioVacca opened this issue Nov 3, 2024 · 1 comment
Open
1 task done
Labels
Needs Triage needs an initial review

Comments

@MaurizioVacca
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

As stated in the title, minipass-fetch fails to resolve/reject when calling response.json() or response.buffer() after fetching certain APIs.

Given the following test

import nodeFetch from 'node-fetch';
import minipassFetch from 'minipass-fetch';


const test_fetch = async () => {
    const deflate = await fetch('https://marine-api.open-meteo.com/v1/marine?latitude=39.0&longitude=9.75&hourly=swell_wave_height,swell_wave_direction,swell_wave_period&models=best_match&timezone=Europe%2FBerlin');
    const deflate_data = await deflate.json();

    const gzip = await fetch('https://jsonplaceholder.typicode.com/todos/1');
    const gzip_data = await gzip.json();

    console.log('test_node_native deflate--', deflate_data.generationtime_ms);
    console.log('test_node_native gzip--', gzip_data.id);
}

const test_node_fetch =  async () => {
    const deflate = await nodeFetch('https://marine-api.open-meteo.com/v1/marine?latitude=39.0&longitude=9.75&hourly=swell_wave_height,swell_wave_direction,swell_wave_period&models=best_match&timezone=Europe%2FBerlin');
    const deflate_data = await deflate.json();

    console.log('test_node_fetch deflate--', deflate_data.generationtime_ms);

    const gzip = await nodeFetch('https://jsonplaceholder.typicode.com/todos/1');
    const gzip_data = await gzip.json();

    console.log('test_node_native gzip--', gzip_data.id);
}

const test_minipass_fetch =  async () => {
    const gzip = await minipassFetch('https://jsonplaceholder.typicode.com/todos/1');
    const gzip_data = await gzip.json();

    console.log('test_minipass_fetch gzip--', gzip_data.id);

    const deflate = await minipassFetch('https://marine-api.open-meteo.com/v1/marine?latitude=39.0&longitude=9.75&hourly=swell_wave_height,swell_wave_direction,swell_wave_period&models=best_match&timezone=Europe%2FBerlin');
    const deflate_data = await deflate.json();

    console.log('test_minipass_fetch deflate--', deflate_data.generationtime_ms);
}

test_fetch();
test_node_fetch();
test_minipass_fetch();

the console.log('test_minipass_fetch deflate--', deflate_data.generationtime_ms); is never printed.

Expected Behavior

Call to response.buffer() should correctly resolve, or at least reject explaining why.

Steps To Reproduce

  1. Setup a new request to https://marine-api.open-meteo.com/v1/marine?latitude=39&longitude=9.5&hourly=swell_wave_height,swell_wave_direction,swell_wave_period&models=best_match&timezone=Europe%2FBerlin.
  2. Execute the request.
  3. Try to access const body = await response.buffer() or const body = await response.json().
  4. See promise being pending indefinitely and never resolving nor rejecting.

Environment

  • npm: 10.2.4
  • Node: v20.11.0
  • OS: macOS Sonoma 14.5
  • platform: Macbook Pro (chipset M3 Pro)
@MaurizioVacca MaurizioVacca added the Needs Triage needs an initial review label Nov 3, 2024
@MaurizioVacca
Copy link
Author

Bump, any news? 👀

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

No branches or pull requests

1 participant