Skip to content

Documentation / @etherfold/core / UnexpectedFromBlockError

Class: UnexpectedFromBlockError ​

Defined in: packages/core/src/errors.ts:96

A batch that did not start where the receiver said it must.

Why this is a TYPE and not a message ​

ADR-0004 makes the receiver authoritative about the cursor, and the whole resumption protocol is this one refusal: the sender is told the block it must re-send from, and it re-sends from there. A caller that has to read expectedFromBlock out of an English sentence is a caller that breaks the next time the sentence is reworded, and an HTTP layer on top has to put that number in a response body. So the number is carried, not narrated.

It is thrown by generateStreamToAppend itself rather than by a check placed in front of it. That matters: a second check would be a second, parallel mechanism that can disagree with the engine, which is exactly what ADR-0004 chose this design to avoid. There is one rule, in one function, and this is the shape it refuses in.

And why it is not an idempotency failure ​

A re-sent batch after a lost acknowledgement lands here, because the cursor has already moved past its fromBlock. That is not an error to paper over: it IS the deduplication. At-least-once on the wire becomes exactly-once in effect, with no dedupe table and no explicit key, because the cursor is the key.

Extends ​

  • Error

Constructors ​

Constructor ​

new UnexpectedFromBlockError(expectedFromBlock, receivedFromBlock): UnexpectedFromBlockError

Defined in: packages/core/src/errors.ts:101

Parameters ​

expectedFromBlock ​

number

Where the next batch must start. The sender re-sends from here.

receivedFromBlock ​

number

Where this batch actually started.

Returns ​

UnexpectedFromBlockError

Overrides ​

Error.constructor

Properties ​

cause? ​

optional cause?: unknown

Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24

Inherited from ​

Error.cause


expectedFromBlock ​

readonly expectedFromBlock: number

Defined in: packages/core/src/errors.ts:103

Where the next batch must start. The sender re-sends from here.


message ​

message: string

Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075

Inherited from ​

Error.message


name ​

readonly name: "UnexpectedFromBlockError" = 'UnexpectedFromBlockError'

Defined in: packages/core/src/errors.ts:97

Overrides ​

Error.name


receivedFromBlock ​

readonly receivedFromBlock: number

Defined in: packages/core/src/errors.ts:105

Where this batch actually started.


retryable ​

readonly retryable: false = false

Defined in: packages/core/src/errors.ts:99

Re-sending the SAME batch never works; the sender re-sends from expectedFromBlock instead.


stack? ​

optional stack?: string

Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076

Inherited from ​

Error.stack

Methods ​

isError() ​

static isError(error): error is Error

Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.esnext.error.d.ts:21

Indicates whether the argument provided is a built-in Error instance or not.

Parameters ​

error ​

unknown

Returns ​

error is Error

Inherited from ​

Error.isError