Skip to content

Cancel/stop replication triggers multipleResolves  #341

@revington

Description

@revington

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions