mirror of
https://github.com/screenci/screenci.git
synced 2026-09-19 08:57:46 +08:00
screenci dev: tolerate empty poll responses instead of warning
An empty 2xx body from the /cli/dev/* proxy (or an idle keep-alive) made postDev's res.json() throw "Unexpected end of JSON input", which the poll loop logged as "Connection problem, retrying" and backed off on. Read the body as text and treat an empty one as an empty result, so an empty poll response is a no-op instead of a spurious connection error.
This commit is contained in:
@@ -103,6 +103,15 @@ describe('pollDevListener', () => {
|
||||
|
||||
await expect(pollDevListener(config, deps, 'lst_1')).resolves.toBeNull()
|
||||
})
|
||||
|
||||
it('treats an empty 2xx body as no trigger instead of throwing', async () => {
|
||||
const deps = makeDeps()
|
||||
// The /cli/dev/* proxy (or an idle keep-alive) can return an empty body;
|
||||
// res.json() on it throws "Unexpected end of JSON input".
|
||||
deps.fetchMock.mockResolvedValueOnce(new Response('', { status: 200 }))
|
||||
|
||||
await expect(pollDevListener(config, deps, 'lst_1')).resolves.toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('runDevListenLoop', () => {
|
||||
|
||||
Reference in New Issue
Block a user