Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: SPA mode fails when loading pages without data #3084

Open
davidklsn opened this issue Feb 10, 2025 · 0 comments
Open

[Bug]: SPA mode fails when loading pages without data #3084

davidklsn opened this issue Feb 10, 2025 · 0 comments
Labels
bug Something isn't working to-review Evidence team to review

Comments

@davidklsn
Copy link

Describe the bug

When using SPA mode, pages that do not load any data fail to render correctly. In my case, the start page had no data and was not working, while all other pages that contained data loaded as expected.
Error Message

The following error is thrown in the console:

Error in client-side routing 
Object { error: SyntaxError, event: {…}, status: 500, message: "Internal Error" }

error: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

event: Object { params: {}, url: URL, route: {…} }

message: "Internal Error"

status: 500

<prototype>: Object { … }

Expected Behavior

Pages without explicit data queries should still render correctly instead of causing a client-side error.

Workaround

Adding a simple query or referencing data in a component fixes the issue. For example, including the following query in the page makes it work:

last_update
SELECT
    date
FROM
    table
ORDER BY date DESC
LIMIT 1;


Last update: <Value data={last_update} />.

Possible Cause

It seems that when there is no data available, the app still expects a JSON response, but instead, it either gets an empty response or an invalid format. This could indicate a missing fallback mechanism in JSON parsing.

Steps to Reproduce

  1. Build evidence app in SPA mode
  2. Serve with `serve build --single
  3. Go to page without data

Logs

Error in client-side routing 
Object { error: SyntaxError, event: {…}, status: 500, message: "Internal Error" }
​
error: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
​
event: Object { params: {}, url: URL, route: {…} }
​
message: "Internal Error"
​
status: 500
​
<prototype>: Object { … }

System Info

Binaries:
    Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
    Yarn: 1.22.21 - ~/.nvm/versions/node/v20.11.1/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
  npmPackages:
    @evidence-dev/bigquery: ^2.0.8 => 2.0.8
    @evidence-dev/core-components: ^5.1.1 => 5.1.1
    @evidence-dev/csv: ^1.0.12 => 1.0.12
    @evidence-dev/databricks: ^1.0.7 => 1.0.7
    @evidence-dev/duckdb: ^1.0.11 => 1.0.11
    @evidence-dev/evidence: ^40.0.7 => 40.0.7
    @evidence-dev/motherduck: ^1.0.2 => 1.0.2
    @evidence-dev/mssql: ^1.0.10 => 1.0.10
    @evidence-dev/mysql: ^1.1.3 => 1.1.3
    @evidence-dev/postgres: ^1.0.6 => 1.0.6
    @evidence-dev/snowflake: ^1.2.0 => 1.2.0
    @evidence-dev/sqlite: ^2.0.6 => 2.0.6
    @evidence-dev/trino: ^1.0.8 => 1.0.8
    @sveltejs/adapter-static: ^3.0.8 => 3.0.1
    @sveltejs/kit: ^2.5.4 => 2.7.3
    @sveltejs/vite-plugin-svelte: ^3.1.2 => 3.1.2
    autoprefixer: ^10.4.0 => 10.4.20
    evidence-connector-aws-athena: ^1.3.1 => 1.3.1
    evidence-connector-s3: ^0.0.2 => 0.0.2
    git-remote-origin-url: ^4.0.0 => 4.0.0
    http-server: ^14.1.1 => 14.1.1
    serve: ^14.2.4 => 14.2.4
    sqlite3: ^5.1.2 => 5.1.7
    svelte: ^4.2.19 => 4.2.19
    vite: ^5.4.10 => 5.4.10

Severity

annoyance

Additional Information, or Workarounds

No response

@davidklsn davidklsn added bug Something isn't working to-review Evidence team to review labels Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working to-review Evidence team to review
Projects
None yet
Development

No branches or pull requests

1 participant