loopbackio / loopbackio/loopback-next

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

Open
#10,529 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
5.1k
Forks
1.1k
Avg merge
2d 21h
Merged PRs (30d)
27

Description

### 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](https://github.com/loopbackio/loopback-next/assets/37167732/23c8f654-b31b-4a1e-8107-293628151bac)
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](https://github.com/loopbackio/loopback-next/assets/37167732/43c61afb-370b-4753-9465-94b3e3ba2439)

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

.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the loopback/rest response path described in the issue and reproduce it with an API returning 500,000 records. Measure the time spent in JSON.stringify and whether liveliness checks remain pending during serialization. Done means the reported response delay and request blocking behavior are addressed, with the result verified against the same large-response scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
api, backend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.