Skip to content

Taco de pulpo #28

@bmount

Description

@bmount

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"
            }   
          }   
        })  
      }   
    }   

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions