From 866f8cd3e021e5e425e20c9c70fde02910a9877a Mon Sep 17 00:00:00 2001 From: alexeyMishinDI Date: Wed, 2 Dec 2026 20:29:16 +0000 Subject: [PATCH 1/3] Fix #700: don't error subscribing to non-table html channels --- code/common/html.q | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/common/html.q b/code/common/html.q index c927c8272..b446ccca0 100644 --- a/code/common/html.q +++ b/code/common/html.q @@ -35,7 +35,7 @@ sel:{[x;y] x} // Apply the modifier before sending the data pub:{[t;x]{[t;x;w]if[count x:sel[x]w 1;(neg first w) modifier[t]@(`upd;t;x)]}[t;x]each w t} -add:{$[(count w x)>i:w[x;;0]?.z.w;.[`.u.w;(x;i;1);union;y];w[x],:enlist(.z.w;y)];(x;$[99=type v:value x;sel[v]y;@[0#v;`sym;`g#]])} +add:{$[(count w x)>i:w[x;;0]?.z.w;.[`.u.w;(x;i;1);union;y];w[x],:enlist(.z.w;y)];(x;$[99=type v:value x;sel[v]y;98=type v;@[0#v;`sym;`g#];()])} sub:{if[x~`;:sub[;y]each t];if[not x in t;'x];del[x].z.w;add[x;y]} // add wssub method - have to subscribe to everything, don't return anything From 959052cea88131acfb1aa285b94c266c102a0692 Mon Sep 17 00:00:00 2001 From: alexeyMishinDI Date: Wed, 2 Dec 2026 20:47:43 +0000 Subject: [PATCH 2/3] Add html pub/sub tests for issue #700 --- tests/html/html.csv | 10 ++++++++++ tests/html/run.sh | 9 +++++++++ 2 files changed, 19 insertions(+) create mode 100644 tests/html/html.csv create mode 100755 tests/html/run.sh diff --git a/tests/html/html.csv b/tests/html/html.csv new file mode 100644 index 000000000..db0501c1e --- /dev/null +++ b/tests/html/html.csv @@ -0,0 +1,10 @@ +action,ms,bytes,lang,code,repeat,minver,comment +before,0,0,q,tsttab:([]time:`timestamp$();sym:`symbol$();val:`long$()),1,,table channel +before,0,0,q,tstfn:{0!select n:count i by sym from tsttab},1,,function channel (like monitor lmchart) +before,0,0,q,.html.init`tsttab`tstfn,1,,register both as pub/sub channels +true,0,0,q,98h=type last .html.sub[`tsttab;`],1,,subscribing to a table still returns an empty copy +true,0,0,q,`sym`time`val~asc cols last .html.sub[`tsttab;`],1,,empty copy has the table's columns +true,0,0,q,()~last .html.sub[`tstfn;`],1,,subscribing to a function channel does not error (#700) +run,0,0,q,.html.wssub each `tsttab`tstfn,1,,websocket subscribe to both like monitor start does +true,0,0,q,all {1=count .html.w[x]} each `tsttab`tstfn,1,,each channel has exactly one subscriber +true,0,0,q,all {.z.w in .html.w[x;;0]} each `tsttab`tstfn,1,,this handle is registered on both channels \ No newline at end of file diff --git a/tests/html/run.sh b/tests/html/run.sh new file mode 100755 index 000000000..0b15a7148 --- /dev/null +++ b/tests/html/run.sh @@ -0,0 +1,9 @@ +#!/bin/bash +source $KDBTESTS/flagparse.sh +testpath=${KDBTESTS}/html +${RLWRAP} q ${TORQHOME}/torq.q \ + -proctype test -procname test1 \ + -test ${testpath} \ + -testresults ${KDBTESTS}/html/results/ \ + -runtime $run \ + $debug $stop $write $quiet \ No newline at end of file From 7ae59f92a55a2da8378c5b64bcd2b1f7b6001e04 Mon Sep 17 00:00:00 2001 From: alexeyMishinDI Date: Thu, 3 Dec 2026 16:16:28 +0000 Subject: [PATCH 3/3] Document non-table html subscriptions --- docs/visualisation.md | 4 ++++ tests/html/run.sh | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/visualisation.md b/docs/visualisation.md index 4934898b4..be3f2ce8d 100755 --- a/docs/visualisation.md +++ b/docs/visualisation.md @@ -106,6 +106,10 @@ kdb+ process and subscribe for updates. Subscriptions are done using .html.wssub[`tablename] +The subscription name does not have to be a table. It can be any name passed +to .html.init, for example the monitor's `lmchart`, which publishes the +output of a function. + Publications from the kdb+ side are done with .html.pub[`tablename;tabledata] diff --git a/tests/html/run.sh b/tests/html/run.sh index 0b15a7148..2d5f31d56 100755 --- a/tests/html/run.sh +++ b/tests/html/run.sh @@ -6,4 +6,4 @@ ${RLWRAP} q ${TORQHOME}/torq.q \ -test ${testpath} \ -testresults ${KDBTESTS}/html/results/ \ -runtime $run \ - $debug $stop $write $quiet \ No newline at end of file + $debug $stop $write $quiet