flutter_js icon indicating copy to clipboard operation
flutter_js copied to clipboard

Fetch request just hangs

Open wardy484 opened this issue 4 years ago • 2 comments

Hi,

I'm trying to debug an issue where a request I'm trying to make to grab some markup just hangs and I can't figure out why. It is worth noting that this request works just fine when using Dio straight from dart. Other requests to the same website also resolve successfully from the JS environment.

My dart code:

JsEvalResult searchRequest = js.evaluate("$src.getChapters(`$id`);");
var newResult = await js.handlePromise(searchRequest);

The offending JS:

export const getChapters = async (mangaId: string): Promise<IChapters> => {
    console.log("starting");

    try {
        const results = await fetch(`${MF_URL}/manga/${mangaId}`);
        
        console.log(await results.text());
        return parseChaptersResult(await results.text(), mangaId);

    } catch (e) {
        console.log("err");
        console.log(e);
    }

    return { chapters: [] };
}

It's worth noting that the JS begins to process just fine as that first console.log executes but the promise never appears to resolve, it could also be worth noting that the response is quite a significant html page. For example, the request seems to resolve on a page that's 5.5kb but just hangs when the page is 21kb? At the moment that's the only obviously differenatiator I've got.

wardy484 avatar Feb 12 '22 22:02 wardy484

@wardy484 Same problem for me fetch hangs!! did you find any fix?

devshahrukhkhan avatar Apr 23 '22 04:04 devshahrukhkhan

I did not in the end I've wound up (hopefully temporarily) running the JS on a remote host.

wardy484 avatar Jun 08 '22 09:06 wardy484