Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taco de pulpo #28

Open
bmount opened this issue Jan 30, 2012 · 0 comments
Open

Taco de pulpo #28

bmount opened this issue Jan 30, 2012 · 0 comments

Comments

@bmount
Copy link
Contributor

bmount commented Jan 30, 2012

I think there is a spot in dataset update from paste api where json is being parsed more than once, leading to the below error:

[2012-01-29 23:01:06.771] [INFO] console - [request] POST http://bvm:******@localhost:5983/dcd667629546bef4b657d5275993013357/_ensure_full_commit

undefined:1
s����   �M
^
SyntaxError: Unexpected token '
    at Object.parse (native)
    at IncomingMessage.<anonymous> (/home/bvm/prg/lang/js/datacouch/node_modules/tako/index.js:423:33)
    at IncomingMessage.<anonymous> (events.js:88:20)
    at IncomingMessage.<anonymous> (/home/bvm/prg/lang/js/datacouch/node_modules/tako/index.js:303:13)
    at IncomingMessage.<anonymous> (events.js:88:20)
    at HTTPParser.onMessageComplete (http.js:137:23)
    at Socket.ondata (http.js:1387:22)
    at TCP.onread (net.js:354:27)
bvm@bvm:~/prg/lang/js/datacouch$ node run.js

Tako index.js after line 420 will quieten with the below, but this feels inconsistent with the rest of the module, like casting to pointer void twice to shut up a compiler, but I just sort of add here in case it is more obvious what unexpected things might be happening, or what should be provisioned beforehand in these cases (ie, starting out a dataset with a paste)

    if (req.method === "PUT" || req.method === "POST") {
      if (req.headers['content-type'] === 'application/json') {
        req.on('body', function (body) {
          try {
            req.emit('json', JSON.parse(body))
          } catch (e) {
            try {
              req.emit('json', body)
            } catch (f) {
              throw "wasnt too parsed"
            }   
          }   
        })  
      }   
    }   
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant