Skip to content

Commit 236b2b6

Browse files
committed
fix(websockets): maintain backwards compatibility of client
1 parent ca913c8 commit 236b2b6

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

oada/services/http-handler/src/websockets.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,25 @@ import EventEmitter from 'eventemitter3';
2424
import type { FastifyPluginAsync } from 'fastify';
2525
import type LightMyRequest from 'light-my-request';
2626
import type WebSocket from 'ws';
27-
import fastifyWebsocket from '@fastify/websocket';
27+
import { default as fastifyWebsocket } from '@fastify/websocket';
2828
import { is } from 'type-is';
2929
import log from 'debug';
3030

3131
import { OADAError } from '@oada/error';
3232

33-
import { KafkaBase, Responder } from '@oada/lib-kafka';
3433
import { changes, resources } from '@oada/lib-arangodb';
34+
import type { KafkaBase } from '@oada/lib-kafka';
35+
import { Responder } from '@oada/lib-kafka';
3536

36-
import SocketRequest, {
37-
// Runtime check for request type
38-
assert as assertRequest,
39-
} from '@oada/types/oada/websockets/request.js';
4037
import type Change from '@oada/types/oada/change/v2.js';
4138
import type SocketChange from '@oada/types/oada/websockets/change.js';
4239
import type SocketResponse from '@oada/types/oada/websockets/response.js';
40+
import type SocketRequest from '@oada/types/oada/websockets/request.js';
4341
import type { WriteResponse } from '@oada/write-handler';
42+
import {
43+
// Runtime check for request type
44+
assert as assertRequest,
45+
} from '@oada/types/oada/websockets/request.js';
4446

4547
/**
4648
* @todo Actually figure out how "forgetting history" should work...
@@ -83,6 +85,8 @@ class Watch {
8385

8486
async sendChange(change: SocketChange) {
8587
trace({ change }, 'Sending change');
88+
// HACK: for backwards compatibility with older clients
89+
change.path_leftover = change.path_leftover ?? [];
8690
await this.#send(JSON.stringify(change));
8791
}
8892

0 commit comments

Comments
 (0)