Skip to content

Loopback/rest stringifies the responce which takes time and hangs the app #10529

Open
@KunalBurangi

Description

@KunalBurangi

Describe the bug

I have a loopback 4 application where I have API which returns large data 500000 records to explain the problem I have added the jaeger trace
image
if you see 1) is my API which has responded in 7-8 sec but the complete API took 12-13 sec
I want to know what happens in those remaining 5-6 sec?

I debugged the API and found out that the control goes to loopback/rest where it is stringifying the response that too using JSON.stringify() and not asyncrously
image

what happens is that during this time all other requests goes pending in my case liveliness check goes pending and as per my configuration if liveliness failed the container restarts .
how to fix this problem ?

Logs

No response

Additional information

Can we do a faster stringify?
or maybe make this asynchronous? I am ready to contribute

Reproduction

.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions