@livestore/webmesh 0.3.2-dev.8 → 0.4.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/node.test.d.ts +1 -1
- package/dist/node.test.d.ts.map +1 -1
- package/dist/node.test.js +23 -33
- package/dist/node.test.js.map +1 -1
- package/package.json +3 -3
- package/src/node.test.ts +23 -61
package/src/node.test.ts
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
import '@livestore/utils-dev/node-vitest-polyfill'
|
|
2
|
-
|
|
3
1
|
import { IS_CI } from '@livestore/utils'
|
|
4
|
-
import {
|
|
5
|
-
Chunk,
|
|
6
|
-
Deferred,
|
|
7
|
-
Effect,
|
|
8
|
-
Exit,
|
|
9
|
-
identity,
|
|
10
|
-
Layer,
|
|
11
|
-
Logger,
|
|
12
|
-
LogLevel,
|
|
13
|
-
Schema,
|
|
14
|
-
Scope,
|
|
15
|
-
Stream,
|
|
16
|
-
WebChannel,
|
|
17
|
-
} from '@livestore/utils/effect'
|
|
18
|
-
import { OtelLiveHttp } from '@livestore/utils-dev/node'
|
|
2
|
+
import { Chunk, Deferred, Effect, Exit, Schema, Scope, Stream, WebChannel } from '@livestore/utils/effect'
|
|
19
3
|
import { Vitest } from '@livestore/utils-dev/node-vitest'
|
|
20
4
|
import { expect } from 'vitest'
|
|
21
5
|
|
|
@@ -209,8 +193,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
209
193
|
|
|
210
194
|
yield* Effect.promise(() => nodeX.debug.requestTopology(100))
|
|
211
195
|
}).pipe(
|
|
212
|
-
|
|
213
|
-
skipOtel: true,
|
|
196
|
+
Vitest.withTestCtx(test, {
|
|
214
197
|
suffix: `delayX=${delayX} delayY=${delayY} connectDelay=${connectDelay} channelType=${channelType} nodeNames=${nodeNames}`,
|
|
215
198
|
}),
|
|
216
199
|
),
|
|
@@ -290,8 +273,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
290
273
|
|
|
291
274
|
yield* Effect.all([nodeACode, nodeBCode], { concurrency: 'unbounded' }).pipe(Effect.withSpan('test'))
|
|
292
275
|
}).pipe(
|
|
293
|
-
|
|
294
|
-
skipOtel: true,
|
|
276
|
+
Vitest.withTestCtx(test, {
|
|
295
277
|
suffix: `waitForOfflineDelay=${waitForOfflineDelay} sleepDelay=${sleepDelay} channelType=${channelType}`,
|
|
296
278
|
}),
|
|
297
279
|
),
|
|
@@ -338,7 +320,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
338
320
|
yield* Effect.all([nodeACode, nodeBCode(nodeBgen2)], { concurrency: 'unbounded' }).pipe(
|
|
339
321
|
Effect.withSpan('test2'),
|
|
340
322
|
)
|
|
341
|
-
}).pipe(
|
|
323
|
+
}).pipe(Vitest.withTestCtx(test)),
|
|
342
324
|
)
|
|
343
325
|
|
|
344
326
|
const ChannelTypeWithoutMessageChannelProxy = Schema.Literal('proxy', 'direct')
|
|
@@ -403,8 +385,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
403
385
|
|
|
404
386
|
yield* Effect.all([nodeXCode, nodeYCode], { concurrency: 'unbounded' })
|
|
405
387
|
}).pipe(
|
|
406
|
-
|
|
407
|
-
skipOtel: true,
|
|
388
|
+
Vitest.withTestCtx(test, {
|
|
408
389
|
suffix: `channelType=${channelType} nodeNames=${nodeNames}`,
|
|
409
390
|
}),
|
|
410
391
|
),
|
|
@@ -459,8 +440,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
459
440
|
concurrency: 'unbounded',
|
|
460
441
|
})
|
|
461
442
|
}).pipe(
|
|
462
|
-
|
|
463
|
-
skipOtel: true,
|
|
443
|
+
Vitest.withTestCtx(test, {
|
|
464
444
|
suffix: `channelType=${channelType} count=${count}`,
|
|
465
445
|
timeout: testTimeout * 2,
|
|
466
446
|
}),
|
|
@@ -500,7 +480,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
500
480
|
}).pipe(Effect.scoped, Effect.repeatN(messageCount))
|
|
501
481
|
|
|
502
482
|
yield* bFiber
|
|
503
|
-
}).pipe(
|
|
483
|
+
}).pipe(Vitest.withTestCtx(test)),
|
|
504
484
|
)
|
|
505
485
|
})
|
|
506
486
|
|
|
@@ -529,7 +509,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
529
509
|
yield* Effect.all([nodeACode, nodeBCode, connectNodes(nodeA, nodeB).pipe(Effect.delay(100))], {
|
|
530
510
|
concurrency: 'unbounded',
|
|
531
511
|
})
|
|
532
|
-
}).pipe(
|
|
512
|
+
}).pipe(Vitest.withTestCtx(test)),
|
|
533
513
|
)
|
|
534
514
|
|
|
535
515
|
Vitest.scopedLive('broadcast edge with message channel', (test) =>
|
|
@@ -541,7 +521,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
541
521
|
|
|
542
522
|
const err = yield* createChannel(nodeA, 'B', { mode: 'direct' }).pipe(Effect.timeout(200), Effect.flip)
|
|
543
523
|
expect(err._tag).toBe('TimeoutException')
|
|
544
|
-
}).pipe(
|
|
524
|
+
}).pipe(Vitest.withTestCtx(test)),
|
|
545
525
|
)
|
|
546
526
|
})
|
|
547
527
|
|
|
@@ -573,7 +553,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
573
553
|
})
|
|
574
554
|
|
|
575
555
|
yield* Effect.all([nodeACode, nodeCCode], { concurrency: 'unbounded' })
|
|
576
|
-
}).pipe(
|
|
556
|
+
}).pipe(Vitest.withTestCtx(test)),
|
|
577
557
|
)
|
|
578
558
|
|
|
579
559
|
Vitest.scopedLive('should work - delayed edge', (test) =>
|
|
@@ -608,7 +588,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
608
588
|
],
|
|
609
589
|
{ concurrency: 'unbounded' },
|
|
610
590
|
)
|
|
611
|
-
}).pipe(
|
|
591
|
+
}).pipe(Vitest.withTestCtx(test)),
|
|
612
592
|
)
|
|
613
593
|
|
|
614
594
|
Vitest.scopedLive('proxy channel', (test) =>
|
|
@@ -633,7 +613,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
633
613
|
})
|
|
634
614
|
|
|
635
615
|
yield* Effect.all([nodeACode, nodeCCode], { concurrency: 'unbounded' })
|
|
636
|
-
}).pipe(
|
|
616
|
+
}).pipe(Vitest.withTestCtx(test)),
|
|
637
617
|
)
|
|
638
618
|
|
|
639
619
|
Vitest.scopedLive('should fail with timeout due to missing edge', (test) =>
|
|
@@ -656,7 +636,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
656
636
|
})
|
|
657
637
|
|
|
658
638
|
yield* Effect.all([nodeACode, nodeCCode], { concurrency: 'unbounded' })
|
|
659
|
-
}).pipe(
|
|
639
|
+
}).pipe(Vitest.withTestCtx(test)),
|
|
660
640
|
)
|
|
661
641
|
|
|
662
642
|
Vitest.scopedLive('should fail with timeout due no transferable', (test) =>
|
|
@@ -677,7 +657,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
677
657
|
})
|
|
678
658
|
|
|
679
659
|
yield* Effect.all([nodeACode, nodeBCode], { concurrency: 'unbounded' })
|
|
680
|
-
}).pipe(
|
|
660
|
+
}).pipe(Vitest.withTestCtx(test)),
|
|
681
661
|
)
|
|
682
662
|
|
|
683
663
|
Vitest.scopedLive('reconnect with re-created node', (test) =>
|
|
@@ -719,7 +699,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
719
699
|
yield* Effect.all([nodeACode, nodeCCode(nodeCgen2)], { concurrency: 'unbounded' }).pipe(
|
|
720
700
|
Effect.withSpan('test2'),
|
|
721
701
|
)
|
|
722
|
-
}).pipe(
|
|
702
|
+
}).pipe(Vitest.withTestCtx(test)),
|
|
723
703
|
)
|
|
724
704
|
})
|
|
725
705
|
|
|
@@ -756,7 +736,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
756
736
|
})
|
|
757
737
|
|
|
758
738
|
yield* Effect.all([nodeACode, nodeDCode], { concurrency: 'unbounded' })
|
|
759
|
-
}).pipe(
|
|
739
|
+
}).pipe(Vitest.withTestCtx(test)),
|
|
760
740
|
)
|
|
761
741
|
})
|
|
762
742
|
|
|
@@ -800,7 +780,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
800
780
|
})
|
|
801
781
|
|
|
802
782
|
yield* Effect.all([nodeACode, nodeECode], { concurrency: 'unbounded' })
|
|
803
|
-
}).pipe(
|
|
783
|
+
}).pipe(Vitest.withTestCtx(test)),
|
|
804
784
|
)
|
|
805
785
|
})
|
|
806
786
|
|
|
@@ -816,7 +796,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
816
796
|
const err = yield* connectNodesViaBroadcastChannel(nodeA, nodeB).pipe(Effect.flip)
|
|
817
797
|
|
|
818
798
|
expect(err._tag).toBe('EdgeAlreadyExistsError')
|
|
819
|
-
}).pipe(
|
|
799
|
+
}).pipe(Vitest.withTestCtx(test)),
|
|
820
800
|
)
|
|
821
801
|
|
|
822
802
|
Vitest.scopedLive('should work for directs', (test) =>
|
|
@@ -841,7 +821,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
841
821
|
})
|
|
842
822
|
|
|
843
823
|
yield* Effect.all([nodeACode, nodeCCode], { concurrency: 'unbounded' })
|
|
844
|
-
}).pipe(
|
|
824
|
+
}).pipe(Vitest.withTestCtx(test)),
|
|
845
825
|
)
|
|
846
826
|
})
|
|
847
827
|
|
|
@@ -881,7 +861,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
881
861
|
})
|
|
882
862
|
|
|
883
863
|
yield* Effect.all([nodeACode, nodeBCode.pipe(Effect.delay(500))], { concurrency: 'unbounded' })
|
|
884
|
-
}).pipe(
|
|
864
|
+
}).pipe(Vitest.withTestCtx(test)),
|
|
885
865
|
)
|
|
886
866
|
|
|
887
867
|
// TODO provide a way to allow for reconnecting in the `listenForChannel` case
|
|
@@ -945,7 +925,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
945
925
|
)
|
|
946
926
|
|
|
947
927
|
yield* Effect.all([nodeACode, nodeBCode], { concurrency: 'unbounded' })
|
|
948
|
-
}).pipe(
|
|
928
|
+
}).pipe(Vitest.withTestCtx(test)),
|
|
949
929
|
)
|
|
950
930
|
|
|
951
931
|
Vitest.describe('prop tests', { timeout: propTestTimeout }, () => {
|
|
@@ -999,8 +979,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
999
979
|
{ concurrency: 'unbounded' },
|
|
1000
980
|
)
|
|
1001
981
|
}).pipe(
|
|
1002
|
-
|
|
1003
|
-
skipOtel: true,
|
|
982
|
+
Vitest.withTestCtx(test, {
|
|
1004
983
|
suffix: `delayNodeA=${delayNodeA} delayNodeC=${delayNodeC} delayConnectAB=${delayConnectAB} delayConnectBC=${delayConnectBC} channelType=${channelType}`,
|
|
1005
984
|
timeout: testTimeout * 2,
|
|
1006
985
|
}),
|
|
@@ -1041,24 +1020,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
1041
1020
|
|
|
1042
1021
|
expect(yield* listenOnAFiber).toEqual('C1')
|
|
1043
1022
|
expect(yield* listenOnCFiber).toEqual('A1')
|
|
1044
|
-
}).pipe(
|
|
1023
|
+
}).pipe(Vitest.withTestCtx(test)),
|
|
1045
1024
|
)
|
|
1046
1025
|
})
|
|
1047
1026
|
})
|
|
1048
|
-
|
|
1049
|
-
const otelLayer = IS_CI ? Layer.empty : OtelLiveHttp({ serviceName: 'webmesh-node-test', skipLogUrl: false })
|
|
1050
|
-
|
|
1051
|
-
const withCtx =
|
|
1052
|
-
(
|
|
1053
|
-
testContext: Vitest.TaskContext,
|
|
1054
|
-
{ suffix, skipOtel = false, timeout = testTimeout }: { suffix?: string; skipOtel?: boolean; timeout?: number } = {},
|
|
1055
|
-
) =>
|
|
1056
|
-
<A, E, R>(self: Effect.Effect<A, E, R>) =>
|
|
1057
|
-
self.pipe(
|
|
1058
|
-
Effect.timeout(timeout),
|
|
1059
|
-
Effect.provide(Logger.pretty),
|
|
1060
|
-
Logger.withMinimumLogLevel(LogLevel.Debug),
|
|
1061
|
-
Effect.scoped, // We need to scope the effect manually here because otherwise the span is not closed
|
|
1062
|
-
Effect.withSpan(`${testContext.task.suite?.name}:${testContext.task.name}${suffix ? `:${suffix}` : ''}`),
|
|
1063
|
-
skipOtel ? identity : Effect.provide(otelLayer),
|
|
1064
|
-
)
|