silentrob / superscript-editor

NOT MAINTAINED - A Editor for authoring chatbots with SuperScript
MIT License
27 stars 16 forks source link

Sorting topic crashes Node #13

Open mariusursache opened 9 years ago

mariusursache commented 9 years ago

Tried sorting the 'random' topic with three triggers (*, hello*, are you *?), and got this error:

/Users/Me/projects/superscript-editor/node_modules/superscript/lib/topics/sort.js:19
    var match  = trig.input.match(/\{weight=(\d+)\}/i);
                     ^
TypeError: Cannot read property 'input' of null
    at Object.exports.sortTriggerSet (/Users/Me/projects/superscript-editor/node_modules/superscript/lib/topics/sort.js:19:22)
    at /Users/Me/projects/superscript-editor/node_modules/superscript/lib/topics/topic.js:70:26
    at /Users/Me/projects/superscript-editor/node_modules/superscript/node_modules/async/lib/async.js:240:13
    at done (/Users/Me/projects/superscript-editor/node_modules/superscript/node_modules/async/lib/async.js:128:19)
    at /Users/Me/projects/superscript-editor/node_modules/superscript/node_modules/async/lib/async.js:25:16
    at /Users/Me/projects/superscript-editor/node_modules/superscript/node_modules/async/lib/async.js:237:17
    at Promise.<anonymous> (/Users/Me/projects/superscript-editor/node_modules/superscript/lib/topics/topic.js:65:9)
    at Promise.<anonymous> (/Users/Me/projects/superscript-editor/node_modules/mongoose/node_modules/mpromise/lib/promise.js:177:8)
    at Promise.emit (events.js:95:17)
    at Promise.emit (/Users/Me/projects/superscript-editor/node_modules/mongoose/node_modules/mpromise/lib/promise.js:84:38)
    at Promise.fulfill (/Users/Me/projects/superscript-editor/node_modules/mongoose/node_modules/mpromise/lib/promise.js:97:20)
    at /Users/Me/projects/superscript-editor/node_modules/mongoose/lib/query.js:1406:13
    at model.Document.init (/Users/Me/projects/superscript-editor/node_modules/mongoose/lib/document.js:254:11)
    at completeOne (/Users/Me/projects/superscript-editor/node_modules/mongoose/lib/query.js:1404:10)
    at Object.cb (/Users/Me/projects/superscript-editor/node_modules/mongoose/lib/query.js:1158:11)
mariusursache commented 9 years ago

As per #14, there are two suggestions for enhancement:

silentrob commented 9 years ago

Drag and Drop topic gambits was pushed last night.

mariusursache commented 9 years ago

Amazing. Can't wait to test it, this was a huge blocker for our project. Thanks a lot! 😀

silentrob commented 9 years ago

Oh great. Had I known you were blocked i would have made it a much higher priority. Sorry about that.

On May 31, 2015, at 11:19 AM, Marius Ursache notifications@github.com wrote:

Amazing. Can't wait to test it, this was a huge blocker for our project. Thanks a lot! 😀

— Reply to this email directly or view it on GitHub.

mariusursache commented 9 years ago

I tested the latest version are there are two issues:

  1. Topic sorting still crashes Node
  2. Manual sorting (drag & drop) only works in the interface. Updating the topic or refreshing the page sets the gambits in a predefined order which does not respect greediness (+ * is greedier than ? *).

Here's the console output for crash:

/Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/superscript/lib/topics/sort.js:19
    var match  = trig.input.match(/\{weight=(\d+)\}/i);
                     ^
TypeError: Cannot read property 'input' of null
    at Object.exports.sortTriggerSet (/Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/superscript/lib/topics/sort.js:19:22)
    at /Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/superscript/lib/topics/topic.js:70:26
    at /Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/superscript/node_modules/async/lib/async.js:240:13
    at done (/Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/superscript/node_modules/async/lib/async.js:128:19)
    at /Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/superscript/node_modules/async/lib/async.js:25:16
    at /Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/superscript/node_modules/async/lib/async.js:237:17
    at Promise.<anonymous> (/Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/superscript/lib/topics/topic.js:65:9)
    at Promise.<anonymous> (/Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/mongoose/node_modules/mpromise/lib/promise.js:177:8)
    at Promise.emit (events.js:107:17)
    at Promise.emit (/Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/mongoose/node_modules/mpromise/lib/promise.js:84:38)
    at Promise.fulfill (/Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/mongoose/node_modules/mpromise/lib/promise.js:97:20)
    at /Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/mongoose/lib/query.js:1406:13
    at model.Document.init (/Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/mongoose/lib/document.js:254:11)
    at completeOne (/Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/mongoose/lib/query.js:1404:10)
    at Immediate.cb (/Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/mongoose/lib/query.js:1158:11)
    at Immediate._onImmediate (/Users/Marius/Repos/project-01/node_modules/superscript-editor/node_modules/mongoose/node_modules/mquery/lib/utils.js:137:16)```

Unfortunately, this does not allow us to create complex gambits/topics at this stage.
silentrob commented 9 years ago

Can you help me reproduce this. First, let me explain how it should work now.

When you create gambits the newst ones always appear at the bottom (within a topic) When you click Sort Topic We apply a algorithm to layer the most greedy gambits on the bottom bases on how many words and what types of wildcards.

If you apply a {weight=XX} it will create new group and order each gambit using the same algorithm but put them into a bucket.

If you use the drag and drop it will update them in real-time but note that his overide sort algorithm and force the order, and this is lost when you hit Sort Topic again.

If the order is not preserved it is most likely because the server crashed and was unable to update, which is indeed a bug.

mariusursache commented 9 years ago

I reinstalled the superscript-editor node module, cleared the DB and it seems that the ordering / server crash happen in a specific case, reproducing it below:

  1. Create 3 gambits in random topic.
  2. Sorting (manually, automatically) works.
  3. Delete one of the gambits
  4. Gambit count still shows 3 gambits in topic table (but only two gambits in the topic page).

image

  1. Sorting manually does not work (updating and refreshing the table keeps previous order)
  2. Sorting automatically crashes node (see previous console log).
silentrob commented 9 years ago

Thanks for the steps. I will see if I can get to the bottom of it.

mariusursache commented 9 years ago

This is a bit of a blocker in working with the editor.