Skip to content

fix(transactions): add ConflictingNonceInMempool to TxRejectedReason … - #1829

Open
Wutche wants to merge 2 commits into
stx-labs:mainfrom
Wutche:fix/1801-add-conflicting-nonce-in-mempool
Open

fix(transactions): add ConflictingNonceInMempool to TxRejectedReason …#1829
Wutche wants to merge 2 commits into
stx-labs:mainfrom
Wutche:fix/1801-add-conflicting-nonce-in-mempool

Conversation

@Wutche

@Wutche Wutche commented Jan 4, 2026 •

Copy link
Copy Markdown

Description

Adds the missing ConflictingNonceInMempool error type to the TxRejectedReason enum and the corresponding ConflictingNonceInMempoolRejection type to TxBroadcastResultRejected.

This error can be returned by Stacks nodes when broadcasting a transaction that has a conflicting nonce with another transaction already in the mempool.

Changes:

  • Added ConflictingNonceInMempool to TxRejectedReason enum in constants.ts
  • Added ConflictingNonceInMempoolRejection type in types.ts
  • Added the new type to TxBroadcastResultRejected union

Closes #1801

Breaking change?

None - this is purely additive.

@janniks @zone117x

Example

import { TxRejectedReason, ConflictingNonceInMempoolRejection } from '@stacks/transactions';

// Now developers can properly handle this rejection type
if (result.reason === TxRejectedReason.ConflictingNonceInMempool) {
  console.log(`Nonce conflict: expected ${result.reason_data.expected}, got ${result.reason_data.actual}`);
}

Checklist

Comment thread packages/transactions/src/types.ts Outdated

export type ConflictingNonceInMempoolRejection = {
reason: 'ConflictingNonceInMempool';
reason_data: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@friedger still waiting for your review

…enum

Adds the missing ConflictingNonceInMempool error type that can be returned
when broadcasting a transaction with a conflicting nonce in the mempool.
Closes stx-labs#1801
@Wutche
Wutche force-pushed the fix/1801-add-conflicting-nonce-in-mempool branch from 75438a7 to ce03642 Compare January 5, 2026 17:00
@Wutche
Wutche requested a review from friedger January 5, 2026 17:00
@jannik-stacks
jannik-stacks requested review from Copilot and removed request for friedger April 8, 2026 12:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds support for the ConflictingNonceInMempool error type to the transaction broadcast error handling in Stacks.js, addressing issue #1801. The changes enable developers to properly handle transactions that have a conflicting nonce with another transaction already in the mempool.

Changes:

  • Added ConflictingNonceInMempool enum value to TxRejectedReason in constants.ts
  • Added ConflictingNonceInMempoolRejection type definition in types.ts
  • Added the new rejection type to the TxBroadcastResultRejected union type

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/transactions/src/constants.ts Added ConflictingNonceInMempool enum value to TxRejectedReason
packages/transactions/src/types.ts Added ConflictingNonceInMempoolRejection type and added it to TxBroadcastResultRejected union

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

} & BaseRejection;

export type ConflictingNonceInMempoolRejection = {
reason: 'ConflictingNonceInMempool';

Copilot AI Apr 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ConflictingNonceInMempoolRejection type is missing the reason_data property that should contain the conflicting nonce information. The PR description's example code shows accessing result.reason_data.expected and result.reason_data.actual, but the type definition doesn't include these fields. This should match the pattern of similar rejection types like BadNonceRejection which includes reason_data with expected and actual fields. Without this, TypeScript will report errors when accessing these properties and the type will not accurately reflect the API response structure.

Suggested change
reason: 'ConflictingNonceInMempool';
reason: 'ConflictingNonceInMempool';
reason_data: {
expected: number;
actual: number;
};

Copilot uses AI. Check for mistakes.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +114 to +116
export type ConflictingNonceInMempoolRejection = {
reason: 'ConflictingNonceInMempool';
} & BaseRejection;

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description/example indicates this rejection includes structured reason_data (e.g., expected/actual nonce), but the new ConflictingNonceInMempoolRejection type doesn’t add any reason_data shape beyond what BaseRejection provides. If the node returns nonce details, please model them here (e.g., add a typed reason_data field) so TS users can safely access result.reason_data.expected/actual; otherwise, update the PR description/example to match the actual payload.

Copilot uses AI. Check for mistakes.
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

Successfully merging this pull request may close these issues.

ConflictingNonceInMempool is missing in the broadcast error enum

4 participants