Comments (7)
Hi @drakhart
Thanks for reporting this issue.
I was able to reproduce your issue and working on fix.
For temporary workaround you can set store.conventions.disableTopologyUpdates = true;
You can track progress here: https://issues.hibernatingrhinos.com/issue/RDBC-626/nodejs-process-doesnt-finish
from ravendb-nodejs-client.
Thanks for investigation.
Please remember DocumentStore should live during application live. There is no point to dispose that when app is running.
Will try to fix setTimeout issue shortly. :)
from ravendb-nodejs-client.
There shouldn't be anything in the session that would cause it to hang.
Can you use https://github.com/mafintosh/why-is-node-running and see what is going on?
from ravendb-nodejs-client.
Sure, I enclose the Why is Node running output below.
Please note: I didn't notice before that using .dispose()
actually allows the Node process to exit, but only after exactly and consistently 16 seconds. In my prior tests I just assumed that the process was stale after more or less 5 seconds and did Ctrl+C. Without .dispose()
it never exits (I waited up to 1 minute just to make sure).
Without .dispose()
Code:
import log from 'why-is-node-running'
import { DocumentStore } from 'ravendb'
const ds = new DocumentStore('http://localhost:8080', 'test').initialize()
ds.openSession()
setTimeout(() => log(), 100)
Output:
There are 5 handle(s) keeping the process running
# TTYWRAP
/Users/drakhart/Documents/poc/ravendb-client/node_modules/bluebird/js/release/debuggability.js:956 - if (util.isNode && process.stderr.isTTY) {
/Users/drakhart/Documents/poc/ravendb-client/node_modules/bluebird/js/release/promise.js:75 - var debug = require("./debuggability")(Promise, Context,
/Users/drakhart/Documents/poc/ravendb-client/node_modules/bluebird/js/release/bluebird.js:9 - var bluebird = require("./promise")();
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Primitives/Timer.js:4 - const BluebirdPromise = require("bluebird");
# Timeout
file:///Users/drakhart/Documents/poc/ravendb-client/index.js:7
# Timeout
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:667 - const cancelTask = setTimeout(() => abortController.abort(), timeout);
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:8 - step((generator = generator.apply(thisArg, _arguments || [])).next());
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:4 - return new (P || (P = Promise))(function (resolve, reject) {
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:662 - return __awaiter(this, void 0, void 0, function* () {
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:598 - const responseAndStream = yield this._sendRequestToServer(chosenNode, nodeIndex, command, shouldRetry, sessionInfo, req, url, controller);
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:8 - step((generator = generator.apply(thisArg, _arguments || [])).next());
# DNSCHANNEL
(unknown stack trace)
# Timeout
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Primitives/Timer.js:19 - this._firstTimeDelayId = setTimeout(() => {
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Primitives/Timer.js:11 - this._schedule(dueTimeInMs);
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:554 - new Timer_1.Timer(function timerActionUpdateTopology() {
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:508 - this._initializeUpdateTopologyTimer();
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:5 - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
With .dispose()
Code:
import log from 'why-is-node-running'
import { DocumentStore } from 'ravendb'
const ds = new DocumentStore('http://localhost:8080', 'test').initialize()
ds.openSession()
ds.dispose()
setTimeout(() => log(), 100)
Output:
There are 4 handle(s) keeping the process running
# TTYWRAP
/Users/drakhart/Documents/poc/ravendb-client/node_modules/bluebird/js/release/debuggability.js:956 - if (util.isNode && process.stderr.isTTY) {
/Users/drakhart/Documents/poc/ravendb-client/node_modules/bluebird/js/release/promise.js:75 - var debug = require("./debuggability")(Promise, Context,
/Users/drakhart/Documents/poc/ravendb-client/node_modules/bluebird/js/release/bluebird.js:9 - var bluebird = require("./promise")();
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Primitives/Timer.js:4 - const BluebirdPromise = require("bluebird");
# Timeout
file:///Users/drakhart/Documents/poc/ravendb-client/index.js:8
# Timeout
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:667 - const cancelTask = setTimeout(() => abortController.abort(), timeout);
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:8 - step((generator = generator.apply(thisArg, _arguments || [])).next());
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:4 - return new (P || (P = Promise))(function (resolve, reject) {
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:662 - return __awaiter(this, void 0, void 0, function* () {
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:598 - const responseAndStream = yield this._sendRequestToServer(chosenNode, nodeIndex, command, shouldRetry, sessionInfo, req, url, controller);
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:8 - step((generator = generator.apply(thisArg, _arguments || [])).next());
# DNSCHANNEL
(unknown stack trace)
from ravendb-nodejs-client.
Looks like bug is here:
If we throw during first request we don't clear timeout and that's the reason test lasts for ~15 seconds.
Could you repeat your test with server that is running, ex. you can use http://live-test.ravendb.net.
If I run this and server is running then dispose on store properly closes and finish node.js app.
If I point to server which can't be reached app runs for 15 seconds and then finish.
Side note:
- you don't have to dispose session
- you should dispose store when applications exist - it holds periodic tasks like connection hearbeats etc - so if you finish program w/o calling dispose on DocumentStore - it won't finish.
from ravendb-nodejs-client.
Sorry, my bad: I didn't notice that my Docker daemon wasn't running after the weekend. I restarted it and ran some more tests.
Here are some updated test cases:
- Connect to running Docker container, without
ds.dispose()
-> process doesn't ever exit (even after 15-16 seconds)
Click here to see output
There are 6 handle(s) keeping the process running
# TTYWRAP
/Users/drakhart/Documents/poc/ravendb-client/node_modules/bluebird/js/release/debuggability.js:956 - if (util.isNode && process.stderr.isTTY) {
/Users/drakhart/Documents/poc/ravendb-client/node_modules/bluebird/js/release/promise.js:75 - var debug = require("./debuggability")(Promise, Context,
/Users/drakhart/Documents/poc/ravendb-client/node_modules/bluebird/js/release/bluebird.js:9 - var bluebird = require("./promise")();
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Primitives/Timer.js:4 - const BluebirdPromise = require("bluebird");
# Timeout
file:///Users/drakhart/Documents/poc/ravendb-client/index.js:7
# DNSCHANNEL
(unknown stack trace)
# TTYWRAP
/Users/drakhart/Documents/poc/ravendb-client/node_modules/node-fetch/lib/index.js:1597 - let body = res.pipe(new PassThrough$1());
# ZLIB
/Users/drakhart/Documents/poc/ravendb-client/node_modules/node-fetch/lib/index.js:1638 - body = body.pipe(zlib.createGunzip(zlibOptions));
# Timeout
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Primitives/Timer.js:19 - this._firstTimeDelayId = setTimeout(() => {
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Primitives/Timer.js:11 - this._schedule(dueTimeInMs);
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:554 - new Timer_1.Timer(function timerActionUpdateTopology() {
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:466 - this._initializeUpdateTopologyTimer();
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:5 - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- Connect to running Docker container, with
ds.dispose()
-> process exits
Click here to see output
There are 5 handle(s) keeping the process running
# TTYWRAP
/Users/drakhart/Documents/poc/ravendb-client/node_modules/bluebird/js/release/debuggability.js:956 - if (util.isNode && process.stderr.isTTY) {
/Users/drakhart/Documents/poc/ravendb-client/node_modules/bluebird/js/release/promise.js:75 - var debug = require("./debuggability")(Promise, Context,
/Users/drakhart/Documents/poc/ravendb-client/node_modules/bluebird/js/release/bluebird.js:9 - var bluebird = require("./promise")();
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Primitives/Timer.js:4 - const BluebirdPromise = require("bluebird");
# Timeout
file:///Users/drakhart/Documents/poc/ravendb-client/index.js:8
# DNSCHANNEL
(unknown stack trace)
# TTYWRAP
/Users/drakhart/Documents/poc/ravendb-client/node_modules/node-fetch/lib/index.js:1597 - let body = res.pipe(new PassThrough$1());
# ZLIB
/Users/drakhart/Documents/poc/ravendb-client/node_modules/node-fetch/lib/index.js:1638 - body = body.pipe(zlib.createGunzip(zlibOptions));
- Connect to live test server, without
ds.dispose()
-> process exits
Click here to see output
There are 7 handle(s) keeping the process running
# TTYWRAP
/Users/drakhart/Documents/poc/ravendb-client/node_modules/bluebird/js/release/debuggability.js:956 - if (util.isNode && process.stderr.isTTY) {
/Users/drakhart/Documents/poc/ravendb-client/node_modules/bluebird/js/release/promise.js:75 - var debug = require("./debuggability")(Promise, Context,
/Users/drakhart/Documents/poc/ravendb-client/node_modules/bluebird/js/release/bluebird.js:9 - var bluebird = require("./promise")();
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Primitives/Timer.js:4 - const BluebirdPromise = require("bluebird");
# Timeout
file:///Users/drakhart/Documents/poc/ravendb-client/index.js:7
# Timeout
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:667 - const cancelTask = setTimeout(() => abortController.abort(), timeout);
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:8 - step((generator = generator.apply(thisArg, _arguments || [])).next());
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:4 - return new (P || (P = Promise))(function (resolve, reject) {
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:662 - return __awaiter(this, void 0, void 0, function* () {
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:598 - const responseAndStream = yield this._sendRequestToServer(chosenNode, nodeIndex, command, shouldRetry, sessionInfo, req, url, controller);
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:8 - step((generator = generator.apply(thisArg, _arguments || [])).next());
# TCPWRAP
/Users/drakhart/Documents/poc/ravendb-client/node_modules/node-fetch/lib/index.js:1468 - const req = send(options);
/Users/drakhart/Documents/poc/ravendb-client/node_modules/node-fetch/lib/index.js:1437 - return new fetch.Promise(function (resolve, reject) {
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RavenCommand.js:107 - const response = yield (0, node_fetch_1.default)(uri, optionsToUse);
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RavenCommand.js:8 - step((generator = generator.apply(thisArg, _arguments || [])).next());
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RavenCommand.js:4 - return new (P || (P = Promise))(function (resolve, reject) {
# DNSCHANNEL
(unknown stack trace)
# HTTPCLIENTREQUEST
(unknown stack trace)
# TCPCONNECTWRAP
(unknown stack trace)
- Connect to live test server, with
ds.dispose()
-> process exits
Click here to see output
There are 7 handle(s) keeping the process running
# TTYWRAP
/Users/drakhart/Documents/poc/ravendb-client/node_modules/bluebird/js/release/debuggability.js:956 - if (util.isNode && process.stderr.isTTY) {
/Users/drakhart/Documents/poc/ravendb-client/node_modules/bluebird/js/release/promise.js:75 - var debug = require("./debuggability")(Promise, Context,
/Users/drakhart/Documents/poc/ravendb-client/node_modules/bluebird/js/release/bluebird.js:9 - var bluebird = require("./promise")();
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Primitives/Timer.js:4 - const BluebirdPromise = require("bluebird");
# Timeout
file:///Users/drakhart/Documents/poc/ravendb-client/index.js:8
# Timeout
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:667 - const cancelTask = setTimeout(() => abortController.abort(), timeout);
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:8 - step((generator = generator.apply(thisArg, _arguments || [])).next());
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:4 - return new (P || (P = Promise))(function (resolve, reject) {
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:662 - return __awaiter(this, void 0, void 0, function* () {
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:598 - const responseAndStream = yield this._sendRequestToServer(chosenNode, nodeIndex, command, shouldRetry, sessionInfo, req, url, controller);
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RequestExecutor.js:8 - step((generator = generator.apply(thisArg, _arguments || [])).next());
# TCPWRAP
/Users/drakhart/Documents/poc/ravendb-client/node_modules/node-fetch/lib/index.js:1468 - const req = send(options);
/Users/drakhart/Documents/poc/ravendb-client/node_modules/node-fetch/lib/index.js:1437 - return new fetch.Promise(function (resolve, reject) {
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RavenCommand.js:107 - const response = yield (0, node_fetch_1.default)(uri, optionsToUse);
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RavenCommand.js:8 - step((generator = generator.apply(thisArg, _arguments || [])).next());
/Users/drakhart/Documents/poc/ravendb-client/node_modules/ravendb/dist/Http/RavenCommand.js:4 - return new (P || (P = Promise))(function (resolve, reject) {
# DNSCHANNEL
(unknown stack trace)
# HTTPCLIENTREQUEST
(unknown stack trace)
# TCPCONNECTWRAP
(unknown stack trace)
I'll try to dispose the document store in my main app after opening a session, as you suggest, and see if that allows it to finish ok.
from ravendb-nodejs-client.
Fixed #333
from ravendb-nodejs-client.
Related Issues (20)
- Feature description update HOT 1
- Using load with includes returns null for documents that were previously stored HOT 2
- Cannot find type definition file for 'stream-json' HOT 2
- Issue with 5.0.1 HOT 3
- Map/Reduce in NodeJs HOT 2
- Can I use the as clause? HOT 2
- TimeSeriesRangeAggregation.asTypedEntry not producing expected results HOT 3
- Getting started error HOT 4
- Serialisation issue HOT 2
- load methods could reasonably return null and interface should reflect that HOT 7
- Activating `queryCustomization.randomOrdering` ignores Collection parameter and returns from all Collections HOT 2
- error TS2507: Type 'typeof FilterBase' is not a constructor function type. HOT 8
- Properly handle large requests using multi byte chars
- Question: check for unsaved changes in session HOT 1
- Map/Reduce TypeError: Object has no method 'flat' HOT 3
- Incorrect ModifiedDocument returned in afterSaveChanges session event HOT 6
- @nested-object-types doesnโt store type information for newly added fields on update HOT 3
- GetDatabaseOperation throws when response is "successfully" a 404 HOT 9
- Type clash with @types/node HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ravendb-nodejs-client.