Node.js Client HiLo Issue

99 views
Skip to first unread message

Troy

unread,
Oct 18, 2017, 2:34:40 AM10/18/17
to RavenDB - 2nd generation document database
Hello,

Using the Node.js client it seems that there is an issue with the HiLo ... it basically doubles the count on every save... see image:



Oren Eini (Ayende Rahien)

unread,
Oct 18, 2017, 3:15:13 AM10/18/17
to ravendb
That is an issue, it should behave like the C# client.

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Wallace Turner

unread,
Oct 28, 2017, 7:17:10 AM10/28/17
to RavenDB - 2nd generation document database


Oren also for some reason the HiLo document is returned when doing a normal query: (there are 5 documents in this collection as per the studio but this query returns 6; 5 plus the HiLo doc)




On Wednesday, 18 October 2017 15:15:13 UTC+8, Oren Eini wrote:
That is an issue, it should behave like the C# client.

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


On Wed, Oct 18, 2017 at 9:34 AM, Troy <tza...@gmail.com> wrote:
Hello,

Using the Node.js client it seems that there is an issue with the HiLo ... it basically doubles the count on every save... see image:



--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.

Oren Eini (Ayende Rahien)

unread,
Oct 29, 2017, 4:39:41 AM10/29/17
to ravendb
Yes, that is a bug in the node.js that was already fixed.
The problem is that we don't send the collection to the server, so it query over all docs.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Wallace Turner

unread,
Oct 29, 2017, 9:33:07 AM10/29/17
to RavenDB - 2nd generation document database
ok so that fix is in the latest github ravendb-nodejs-client but not in the npm package?

Wallace Turner

unread,
Oct 29, 2017, 11:54:39 PM10/29/17
to RavenDB - 2nd generation document database
ok the fix is in latest codebase. as an aside i think you need to declare some of your typings as a npm dependancy and not a devDependencies as per the official typescript publishing documentation [1]:
The following quote is from that page:


Our package exposes declarations from each of those, so any user of our browserify-typescript-extension package needs to have these dependencies as well. For that reason, we used "dependencies" and not "devDependencies", because otherwise our consumers would have needed to manually install those packages. 


So in the top of ravendb-node.d.ts you have:

/// <reference types="node" />
/// <reference types="request-promise" />
/// <reference types="request" />
/// <reference types="async-lock" />
/// <reference types="bluebird" />
import * as BluebirdPromise from 'bluebird';
import * as AsyncLock from 'async-lock';
import * as EventEmitter from 'events';
import * as Request from 'request';
import * as RequestPromise from 'request-promise';


however in *your* package.json these packages are listed under`devDependencies` instead of `dependencies` and thus am forced to add them to my own package.json to avoid the following typescript errors:

node_modules/ravendb/lib/ravendb-node.d.ts(2,1): error TS2688: Cannot find type definition file for 'request-promise'.
node_modules/ravendb/lib/ravendb-node.d.ts(3,1): error TS2688: Cannot find type definition file for 'request'.
node_modules/ravendb/lib/ravendb-node.d.ts(4,1): error TS2688: Cannot find type definition file for 'async-lock'.
node_modules/ravendb/lib/ravendb-node.d.ts(5,1): error TS2688: Cannot find type definition file for 'bluebird'.





Grzegorz Lachowski

unread,
Oct 30, 2017, 4:04:37 AM10/30/17
to RavenDB - 2nd generation document database
Wallace,
I logged it. You can track the work here http://issues.hibernatingrhinos.com/issue/RDBC-51

Regards,
Greg

Wallace Turner

unread,
Oct 30, 2017, 6:25:50 AM10/30/17
to RavenDB - 2nd generation document database
please note i do not have permissions to view that page

it must have something to do with the RDBC project within youtrack as i'm able to view RavenDB-xxxx issues no problem
enable guest ?

Oren Eini (Ayende Rahien)

unread,
Oct 30, 2017, 6:27:39 AM10/30/17
to ravendb
It's open now
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Wallace Turner

unread,
Oct 30, 2017, 6:29:30 AM10/30/17
to RavenDB - 2nd generation document database
could you please push the latest codebase to npm ?

Troy

unread,
Oct 30, 2017, 10:30:41 AM10/30/17
to RavenDB - 2nd generation document database
+1 One for updating NPM for node client.

Wallace Turner

unread,
Oct 30, 2017, 11:17:11 AM10/30/17
to RavenDB - 2nd generation document database
also are you aware there are roughly 20 typescript compilation errors?
7 of these are `Property 'includes' does not exist on type x` which could be fixed by using  [ ].indexOf(x) >= 0   (for some reason typescript is not transpiling Prototype.array.includes)
some of the others i've looked at require a bit more input on the business side, eg generateId in  DocumentStore.ts
>src/Documents/DocumentStore.ts(168,5): error TS2322: Type 'string | void' is not assignable to type 'string'.
 
Type 'void' is not assignable to type 'string'.


code:
    return this._generator.generateDocumentId(document, documentType, database)
     
.then((id: string) => {
       
PromiseResolver.resolve<string>(id, null, callback);
       
return id;
     
})
     
.catch((error: RavenException) => PromiseResolver.reject(error, null, callback));

you are catching that error (`PromiseResolver.reject) however the method returns simply a string (not string | void)
It may be better to not catch that there and handle any errors further up ? (e.g prepareDocumentIdBeforeStore)

Grzegorz Lachowski

unread,
Oct 31, 2017, 3:23:53 AM10/31/17
to RavenDB - 2nd generation document database
Wallace,

I tried building latest 4.0 branch. All builds fine when node 8 is used, but I got errors when built with node 6 (12 of them). I logged this here: http://issues.hibernatingrhinos.com/issue/RDBC-52
Can you please tell us how were you able to get 20 errors? Do you use our npm scripts or just build it with tsc?

Regards,
Greg

Wallace Turner

unread,
Oct 31, 2017, 3:50:06 AM10/31/17
to RavenDB - 2nd generation document database
yes agreed 12 errors when using node 6 (what I'm using) using your npm build script

the 20 or so errors are when I am using tsc -w are as follows: (19)

src/Database/Commands/PatchCommand.ts(62,52): error TS2339: Property 'includes' does not exist on type 'StatusCode[]'.
src/Database/Operations/OperationAwaiter.ts(87,18): error TS2346: Supplied parameters do not match any signature of call target.
src/Documents/DocumentStore.ts(168,5): error TS2322: Type 'string | void' is not assignable to type 'string'.
  Type 'void' is not assignable to type 'string'.
src/Documents/Session/DocumentQuery.ts(208,5): error TS2322: Type 'void | T' is not assignable to type 'T'.
  Type 'void' is not assignable to type 'T'.
src/Documents/Session/DocumentQuery.ts(218,18): error TS2346: Supplied parameters do not match any signature of call target.
src/Documents/Session/DocumentQuery.ts(241,5): error TS2322: Type 'void | T' is not assignable to type 'T'.
  Type 'void' is not assignable to type 'T'.
src/Documents/Session/DocumentQuery.ts(264,5): error TS2322: Type 'number | void' is not assignable to type 'number'.
  Type 'void' is not assignable to type 'number'.
src/Documents/Session/DocumentQuery.ts(281,5): error TS2322: Type 'void | T[] | QueryResultsWithStatistics<T>' is not assignable to type 'T[] | QueryResultsWithStatistics<T>'.
  Type 'void' is not assignable to type 'T[] | QueryResultsWithStatistics<T>'.
src/Documents/Session/DocumentQuery.ts(789,42): error TS2339: Property 'includes' does not exist on type 'string[]'.
src/Documents/Session/DocumentSession.ts(138,5): error TS2322: Type 'void | T | T[]' is not assignable to type 'T | T[]'.
  Type 'void' is not assignable to type 'T | T[]'.
src/Documents/Session/DocumentSession.ts(258,5): error TS2322: Type 'void | T' is not assignable to type 'T'.
  Type 'void' is not assignable to type 'T'.
src/Documents/Session/Query/QueryBuilder.ts(859,61): error TS2339: Property 'includes' does not exist on type 'string[]'.
src/Hilo/HiloIdGenerator.ts(84,18): error TS2346: Supplied parameters do not match any signature of call target.
src/Http/Request/NodeSelector.ts(104,15): error TS2339: Property 'includes' does not exist on type 'ServerNode[]'.
src/Http/Request/RequestExecutor.ts(221,11): error TS2339: Property 'includes' does not exist on type 'StatusCode[]'.
src/Http/Request/RequestExecutor.ts(295,14): error TS2346: Supplied parameters do not match any signature of call target.
src/Http/Topology.ts(37,47): error TS2345: Argument of type '(url: string, tag: string) => number' is not assignable to parameter of type 'ObjectIterator<string, any>'.
  Types of parameters 'url' and 'value' are incompatible.
    Type 'number | ((index: number) => number) | ((...strings: string[]) => string) | ((searchString: strin...' is not assignable to type 'string'.
      Type 'number' is not assignable to type 'string'.
src/Utility/StringUtil.ts(50,46): error TS2339: Property 'includes' does not exist on type 'string[]'.
src/Utility/StringUtil.ts(58,66): error TS2339: Property 'includes' does not exist on type 'string[]'.

Troy

unread,
Oct 31, 2017, 9:31:27 PM10/31/17
to RavenDB - 2nd generation document database
Can we get an NPM update since 51 and 52 are merged as well as the HiLo issues? Thanks.

Wallace Turner

unread,
Oct 31, 2017, 10:05:49 PM10/31/17
to RavenDB - 2nd generation document database
Greg you might also want to fix a mistake in the docs for `addDocumentInfoResolver` (2 places)
I think you need to reference the type name in the returned require field (see green highlight below)


store.conventions.addDocumentInfoResolver({
 
resolveConstructor: (typeName: string): DocumentConstructor =>
   
<DocumentConstructor>require(`./models/${typeName}`)[typeName]
});

should be

Wallace Turner

unread,
Oct 31, 2017, 11:00:38 PM10/31/17
to RavenDB - 2nd generation document database
Also Greg, I've figured out why `includes` wasnt working (even with 51 and 52 commits)
The `lib` in your tsconfig is in the wrong place. You have it nested under the root object when it should be under `compilerOptions`
see below. move it from aqua to the green region



{
 
"version": "2.5.3",
 
"compilerOptions": {
   
"target": "es2015",
   
"module": "commonjs",
   
"declaration": true,
   
"outDir": "lib/",
   
"sourceMap": false,
   
"lib": ["dom", "es7" ]
 
},
 
"files": [
   
"./src/ravendb-node.ts"
 
],
 
"exclude": [
   
"node_modules",
   
"lib"
 
],
 
"lib": ["dom", "es7" ]
}

Oren Eini (Ayende Rahien)

unread,
Nov 1, 2017, 4:09:18 AM11/1/17
to ravendb
Wallace, I just wanted to stop for a moment and thank you for your feedback. 
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Wallace Turner

unread,
Nov 1, 2017, 6:29:01 AM11/1/17
to RavenDB - 2nd generation document database
No worries, I assume this is the correct place to send corrections.
With the free tier I think you will have an influx (perhaps slowly at first) of people looking at mongo alternatives or at noSQL in general  especially in the node js space...

Oren Eini (Ayende Rahien)

unread,
Nov 1, 2017, 7:43:26 AM11/1/17
to ravendb
That's the hope
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages