noopkat / ms-bing-speech-service

NodeJS service wrapper for Microsoft Speech API and Custom Speech Service
MIT License
82 stars 17 forks source link

SyntaxError: Unexpected end of JSON input #14

Closed danreeves closed 6 years ago

danreeves commented 6 years ago

node --version: v9.2.0 ms-bing-speech-service: 2.0.0

I'm probably doing something wrong, but when I try sending a Buffer the JSON.parse in onMessage is exploding because message.body is just {.

Example message:

{ 'x-requestid': '[an alpha num]',
  'content-type': 'application/json; charset=utf-8',
  path: 'turn.start',
  body: [String: '{'],
  '"context"': '{',
  '"servicetag"': '"[an alpha num]"' }
noopkat commented 6 years ago

ah shoot ๐Ÿคจ thanks for reporting!

It seems that the incoming message parser is imperfect, and it should not be failing on this. I have patchy internet at the airport right now so I'm having trouble replicating, but will write an extra test for turn.start message parsing and try to get it behaving properly.

noopkat commented 6 years ago

ok, I think I know what happened. I forgot to build the node entry file before publishing. All the same, I added some more robustness around the parser and tweaked my test message data to more accurately represent the line breaks on messages coming in from the websocket.

once the tests pass in CI I'll merge it and publish. Would love if you could then retest please :pray:

noopkat commented 6 years ago

๐Ÿšข ๐Ÿšข ๐Ÿšข just shipped the fix.

Please reopen if you still run into issues. Thanks for testing out the major release so soon!

bitmoji

danreeves commented 6 years ago

Speedy response! ๐Ÿš€

Looks like that fixed the issue, thanks!