You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The displayed results shows (e.g.) only a single row.
Actual Behaviour
The SQL Query text changes ("Show SQL"), but the number of rows stays unchanged (= multiple rows).
Reloading the whole page manually does finally display the correct result, though.
Workarounds
When starting the dev server BEFORE creating the page, and then navigating to it (needs more than 1 page), SQL changes directly lead to correct results after HMR. Also, AFAICT #1341 scroll-to-top seems to happen less frequently...
Thus, the old (wrong) [hash].arrow-Data is used again, leading to the observed lost sync between sql query text and sql query result.
When creating the page after starting the dev server, the new page's queries are never added to the pre-rendered result cache, leading to empty initialData; the client-side obtained result against the parquet file are always correct, before and after HMR.
// rerun if data changes during dev mode, likely source HMR, prevent initial for same reason as above
let _${id}_hmr_once = false;
$: if (dev) {
if (_${id}_hmr_once) {
data;
__has_hmr_run; // <-- add dependency
_${id}_debounced_updater();
} else {
_${id}_hmr_once = true;
}
}
(This does not improve the situation w/ #1341 any more, though.)
Steps To Reproduce
Create
index.md
with inline sql query returning multiple rows and display results (e.g. chart, datatable, "show sql", ...).Start dev server, open page in browser
/api/[...]/[...]/all-queries.json
is correctly loadedQueryStore
should now have.opts.initialData
as array w/ the expected length (= number of rows).index.md
add (e.g.)LIMIT 1
to reduce the number of rows. HMR will reload the page in the browser. The page might scroll to the top (Page jumps to the top on HMR changes in some cases #1341 seems to be somewhat related).Environment
node -v
): v20.11.1Expected Behavior
The displayed results shows (e.g.) only a single row.
Actual Behaviour
The SQL Query text changes ("Show SQL"), but the number of rows stays unchanged (= multiple rows).
Reloading the whole page manually does finally display the correct result, though.
Workarounds
When starting the dev server BEFORE creating the page, and then navigating to it (needs more than 1 page), SQL changes directly lead to correct results after HMR. Also, AFAICT #1341 scroll-to-top seems to happen less frequently...
Alternatively, adding
opts.initialDataDirty = true
unconditionally, e.g. here: https://github.com/evidence-dev/evidence/blob/next/packages/query-store/src/QueryStore.ts#L233 "fixes" the problem.(I believe there are additional cases where
all-queries.json
is not loaded, which do work correctly.)Explanation
HMR (on the server side) does not seem to notice the inline sql changes – it definitely doesn't act on them.
This means:
all-queries.json
stays unchanged, and the client only loadsapp.css
and+page.md
via the HMR trigger.The injected svelte code in
+page.md
, https://github.com/evidence-dev/evidence/blob/next/packages/lib/preprocess/src/process-queries.cjs#L112 relies on the sql block name (id
) to obtain theinitialData
,which ultimately comes from
getPrerenderedQueries()
(e.g. https://github.com/evidence-dev/evidence/blob/next/sites/example-project/src/pages/%2Blayout.js#L47), which is also not called again; but even if it would, it usesall-queries.json
, which is still unchanged on the server.Thus, the old (wrong)
[hash].arrow
-Data is used again, leading to the observed lost sync between sql query text and sql query result.When creating the page after starting the dev server, the new page's queries are never added to the pre-rendered result cache, leading to empty
initialData
; the client-side obtained result against the parquet file are always correct, before and after HMR.https://github.com/evidence-dev/evidence/blob/next/packages/lib/preprocess/src/process-queries.cjs#L93 includes (basically)
_${id}_changed = _${id}_current_query !== _${id}_initial_query
to force emptyinitialData
, but this does not capture the case at hand – and, according to the comments there, wasn't meant to.And finally, QueryStore's
backgroundFetch
, although executed, does not help, because it just throws away the (correct) result.The text was updated successfully, but these errors were encountered: