From a196a61b0a55b2deac56454c206c45340052f970 Mon Sep 17 00:00:00 2001 From: Gregor MacLennan Date: Mon, 9 Feb 2026 18:23:54 +0000 Subject: [PATCH 1/2] chore: failing tests for missing error.message in state --- test/map-shares.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/map-shares.test.ts b/test/map-shares.test.ts index 3c81d6a..e218e81 100644 --- a/test/map-shares.test.ts +++ b/test/map-shares.test.ts @@ -361,6 +361,7 @@ describe('Map Shares and Downloads', () => { 'error.code', 'DOWNLOAD_SHARE_NOT_PENDING', ) + expect(events.at(-1)).toHaveProperty('error.message') await completedPromise }, 2000) @@ -385,6 +386,7 @@ describe('Map Shares and Downloads', () => { 'error.code', 'DOWNLOAD_SHARE_NOT_PENDING', ) + expect(events.at(-1)).toHaveProperty('error.message') }) }) @@ -582,6 +584,7 @@ describe('Map Shares and Downloads', () => { 'error.code', 'DOWNLOAD_SHARE_DECLINED', ) + expect(events.at(-1)).toHaveProperty('error.message') }) it('should reject decline on non-pending share', async (t) => { @@ -1590,6 +1593,7 @@ describe('Map Shares and Downloads', () => { .json() expect(downloadStatus.status).toBe('error') expect(downloadStatus).toHaveProperty('error.code', 'DOWNLOAD_ERROR') + expect(downloadStatus).toHaveProperty('error.message') }) it('should clean up temp files on download error', async (t) => { From 1e2e1afb9a3aa14e26f2e1140e9955d5f4180e7d Mon Sep 17 00:00:00 2001 From: Gregor MacLennan Date: Mon, 9 Feb 2026 18:24:12 +0000 Subject: [PATCH 2/2] fix: fix missing error.message in download and map share state --- src/lib/download-request.ts | 2 +- src/lib/map-share.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/download-request.ts b/src/lib/download-request.ts index c3b94fa..43d14a0 100644 --- a/src/lib/download-request.ts +++ b/src/lib/download-request.ts @@ -67,7 +67,7 @@ export class DownloadRequest extends TypedEventTarget< this.#updateState({ status: 'canceled' }) } else if (getErrorCode(error)) { // Specific known error from the server - this.#updateState({ status: 'error', error }) + this.#updateState({ status: 'error', error: jsonError(error) }) } else { // Once the download has started, the sender can only close the // connection to cancel the download, which we only see as an diff --git a/src/lib/map-share.ts b/src/lib/map-share.ts index a795dc9..2178706 100644 --- a/src/lib/map-share.ts +++ b/src/lib/map-share.ts @@ -5,7 +5,7 @@ import { type DownloadStateUpdate, type MapInfo, } from '../types.js' -import { errors } from './errors.js' +import { errors, jsonError } from './errors.js' import { StateUpdateEvent } from './state-update-event.js' import { addTrailingSlash, generateId, getErrorCode } from './utils.js' @@ -155,7 +155,7 @@ export class DownloadResponse extends TypedEventTarget< } else if (getErrorCode(error) === 'ECONNRESET') { this.#updateState({ status: 'aborted' }) } else { - this.#updateState({ status: 'error', error }) + this.#updateState({ status: 'error', error: jsonError(error) }) } })