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

fix(svelte): Ensure client is loaded before use #465

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

c12i
Copy link
Collaborator

@c12i c12i commented Feb 17, 2025

Closes #466

This PR adds measures to ensure the client is not accessible before its initialized. This is achieved by moving the client state to a global state and and sharing it across child components.

Blocked by failing CI

@c12i c12i changed the title fix: Ensure svelte client is loaded fix(svelte): Ensure client is loaded before use Feb 17, 2025
@c12i c12i marked this pull request as draft February 17, 2025 13:45
@c12i c12i marked this pull request as ready for review March 4, 2025 12:38
@c12i c12i requested a review from a team March 4, 2025 13:31
Copy link

@jost-s jost-s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lexically LGTM. Can I test this somehow or even better, is this tested on CI somehow? If not, can it be?

@c12i
Copy link
Collaborator Author

c12i commented Mar 4, 2025

Can I test this somehow or even better

You can test this locally by checking out this repo, installing scaffolding via cargo install --path . then running hc scaffold example forum to spin up a test forum app with svelte

is this tested on CI somehow? If not, can it be?

For now, are only ensuring that the ui generated by scaffolding can be built without producing any vite build or typescript errors.

We had a discussion on testing the UI in the past on this spike #421, ready for refinement

@@ -1,7 +1,83 @@
import { type AppClient } from "@holochain/client";
import { writable, type Writable } from 'svelte/store';
import { getContext, setContext } from 'svelte';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { getContext, setContext } from 'svelte';
import { getContext } from 'svelte';

setContext is not used

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, thanks

@@ -1,7 +1,83 @@
import { type AppClient } from "@holochain/client";
import { writable, type Writable } from 'svelte/store';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { writable, type Writable } from 'svelte/store';
import { get, writable } from 'svelte/store';

type Writable not used, get missing

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks

import { type ClientContext, clientContext } from '../../contexts';
import { onMount } from 'svelte';
import type { EntryHash, Record, AgentPubKey, ActionHash, Link, NewEntryAction, HolochainError } from '@holochain/client';
import { SignalType } from '@holochain/client';
Copy link
Member

@mattyg mattyg Mar 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SignalType was removed from holochain-client-js due to changes in enum serialization: see https://github.com/holochain/holochain-client-js/pull/322/files#

I think there's a few other places in this PR that use it.

Copy link
Collaborator Author

@c12i c12i Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, this was a left over change while fixing merge conflicts, thanks for catching

@mattyg
Copy link
Member

mattyg commented Mar 4, 2025

I'm running into a few unrelated issues that are preventing me from testing this:

  • When I run npm run start, I get an error from hc-spin that the request to issue an app auth token timed out:
[1] (node:976325) UnhandledPromiseRejectionWarning: Error: Request timed out in 60000 ms: issue_app_authentication_token
[1]     at Timeout.<anonymous> (/home/matt/Projects/Holochain/forum/node_modules/@holochain/hc-spin/dist/main/index.js:4576:34)
[1]     at listOnTimeout (node:internal/timers:573:17)
[1]     at process.processTimers (node:internal/timers:514:7)
[1] (Use `electron --trace-warnings ...` to show where the warning was created)
[1] (node:976325) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
  • When I run npm run start:tauri, I get an error that the conductor config is invalid:
[1] [1] 2025-03-04T23:30:50.857592Z  WARN kitsune_p2p::spawn: crates/kitsune_p2p/kitsune_p2p/src/spawn.rs:31: gossip_arc_clamping network tuning parameter is not set. This is not permitted without "unstable-sharding" feature enabled. Please choose either "empty" or "full"
[1] [1] 2025-03-04T23:30:50.857671Z ERROR holochain::conductor::conductor::builder: crates/holochain/src/conductor/conductor/builder.rs:275: Error spawning networking err=OtherKitsuneP2pError(Other(OtherError("gossip_arc_clamping must be set")))

I'll make issues in the corresponding repos. Have you been able to run this @c12i?

@c12i
Copy link
Collaborator Author

c12i commented Mar 5, 2025

I'll make issues in the corresponding repos.

Feel free to open, I suspect the error might be related to the change in enum serialization as well. Last manual testing was done on dev.18 and things were working then prior to rebasing from main

@matthme
Copy link
Contributor

matthme commented Mar 5, 2025

I'm running into a few unrelated issues that are preventing me from testing this

I'm working on bumping hc-spin and hc-launch right now. hc-launch PR is ready for review here. Once merged, I will udpate holonix.

@c12i c12i requested review from mattyg and jost-s March 6, 2025 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FIX] Improve client loading for svelte template
4 participants