iliakan / iliakan/nodejs-screencast

Некорректное чтение или преобразования

Open
#9 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
301
Forks
144
PR merge metrics
No merged PRs in 30d

Description

# long-poll-chat

https://github.com/iliakan/nodejs-screencast/blob/master/long-poll-chat/server.js#L23
в строке где body +=req.read();
req.read() последним значением возвращает null, что приводит к строке, например:
{"message":"привет"}null
и соответственно в строке body = JSON.parse(body); появляется ошибка.
Для того чтобы json был валидным
нужно сделать проверку на null
var req_read = req.read();
if(req_read != null) body += req_read;

Contributor guide

No contributing guide indexed for this repository

Research direction

Inspect server.js at line 23, where req.read() is appended to the request body before JSON.parse(body). Handle the final null value so it is not included in the body, then verify that the example request remains valid JSON and no longer causes the parse error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.