Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancel/stop replication triggers multipleResolves #341

Open
revington opened this issue Feb 15, 2024 · 0 comments
Open

Cancel/stop replication triggers multipleResolves #341

revington opened this issue Feb 15, 2024 · 0 comments

Comments

@revington
Copy link
Contributor

Expected Behavior

I should be able to cancel replication without triggering multipleResolves. Or at least this is what I think because according with node.js docs this could be a bug or not.

This is useful for tracking potential errors in an application while using the Promise constructor, as multiple resolutions are silently swallowed. However, the occurrence of this event does not necessarily indicate an error.

-- https://nodejs.org/docs/latest/api/process.html#event-multipleresolves

Current Behavior

Everytime I cancel a replication I trigger a couple of rejects.

Possible Solution

Not sure because this might be more of an axios issue. But using an abort controller might be a solution.

Steps to Reproduce (for bugs)

'use strict';
require('dotenv').config();
const couchdb = require('nano')(process.env.COUCHDB);
process.on('multipleResolves', function multipleResolvesHandler (type, promise, reason) {
	console.error('multiple resolve', { type, promise, reason });
	setImmediate(() => process.exit(1));
});

let reader = couchdb.changesReader.start({
	includeDocs: true
	, batchSize: 25
	, since: 0
});

reader.on('end', function () {
	console.log('done');
});

couchdb.changesReader.stop(); // triggers an error

reader.once('batch', function onBatch (batch) {
	console.log('got batch', !!batch);
	couchdb.changesReader.stop();
});

Context

I can not tell if I'm having an error I should care or not.

Your Environment

  • nano 10.1.3
  • couchdb 3.1
  • node 16.15.1 (linux)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant