Hang querying empty result #10
Labels
No labels
dependencies
javascript
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
quodatum/basex-node#10
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
package.json: "basex": "~0.6.1"
I create a database, insert a document, and then query for something that is not there.
I am using BaseX 7.6 if that makes any difference.
Maybe you can see it. Here's the debug of what goes back and forth during the whole session:
S1<<
'1374588092554420000\u0000'
S1>>
'admin\u0000'
S1>>
'713de454606e785a0666bd57e6554891\u0000'
S1<<
'\u0000'
S1: authorized
S1>>
'create db gumby\u0000'
S1<<
'\u0000Database 'gumby' created in 5.01 ms.\n\u0000\u0000'
response: { result: '',
info: 'Database 'gumby' created in 5.01 ms.\n',
ok: true }
.S1>>
'\t/people.xml\u0000Gumby\nmanelsePokey\nhorse\u0000'
S1<<
'Path "people.xml" added in 1.88 ms.\n\u0000\u0000'
response: { ok: true, result: 'Path "people.xml" added in 1.88 ms.\n' }
.S1>>
'\u0000//somethingNotThere\u0000'
S1<<
'0\u0000\u0000'
response: { ok: true, result: '0' }
S1>>
'\u00040\u0000'
S1<<
'\u0000\u0000'
And then it hangs, since the callback isn't called.
If, instead, I do a query that does give results back I get the first value prefixed with \000b, which I believe is intended to indicate that the result is an "element".
S1<<
'\u000bGumby\nman\u0000\u000bPokey\nhorse\u0000\u0000\u0000'
response: { ok: true,
result:
[ '\u000bGumby\nman',
'Pokey\nhorse' ] }
{"ok":true,"result":["\u000bGumby\nman","Pokey\nhorse"]}
It seems I was able to fix it by adjusting the popByte in parser2.js:
I added the checking if there was anything in the buffer.
That looks good to me. Fixed in v0.6.2 on github and soon npm.
Thanks
Isn't there a danger that this leads to a tight loop while it is waiting for a reply?
If there is no
progressi.e. nothing to parse in theparseResultsfunction then it should exit and only be called again on a data event. At least that is the intent.Ah you're right. My returning of null when there's nothing in the buffer causes the while(progress) loop to exit. I guess it can be closed after all.
Great. I still think there must be a better approach to the whole async parsing process, but that is for another day.