Skip to content

Conversation

@Twey
Copy link
Contributor

@Twey Twey commented Nov 19, 2025

Motivation

We'd like to be able to backport the OOM fix to testnet_conway.

Proposal

Get testnet_conway up-to-date with respect to web changes on main, up to and including:

Test Plan

CI. Includes a PR that introduces (some) testing for the Web. Hopefully I didn't miss anything.

Release Plan

  • Nothing to do / These changes follow the usual release cycle.

Links

Twey added 3 commits November 18, 2025 20:06
## Motivation

We are unhappy with the directory structure of `linera-web`, which looks
too much like an SDK crate.

## Proposal

Rename it to plain old `web` to indicate that it's not (published as) a
crate, with the npm package structure (`@linera/client` and
`@linera/signer`) reproduced inside.

## Test Plan

CI.

## Release Plan

- Nothing to do / These changes follow the usual release cycle.

## Links

- [reviewer
checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
## Motivation

In linera-io#4577 I moved the npm packages around, but I forgot to update the
pnpm workspace file.

## Proposal

Update it with the new package paths.

## Test Plan

Tested locally.

## Release Plan

- Nothing to do / These changes follow the usual release cycle.

## Links

- [reviewer
checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
It's currently difficult to test the `@linera/client` package in
isolation because it always requires a `Signer` instance to use, the
most straightforward one of which is the `PrivateKey` signer that lives
in `@linera/signer`.

Integrate the private-key signer into the `@linera/client` package next
to the `Signer` interface itself as `linera.PrivateKeySigner`.

While we're breaking the API, fix up the package structure of
`@linera/client` a bit (giving us a barrel file as a cleaner place to
inject TypeScript code to live next to the Wasm and its generated shim),
and remove some vestigial functions (`Signer.get_public_key()`, which is
never used any more, and `Client.frontend()`, which made more sense when
this library was intended to be the direct implementation of a Web
extension).

Since the erstwhile `@linera/signer` package now only contains the
MetaMask signer, rename it to `@linera/metamask` and open up its scope
to other MetaMask-specific signers and integrations.

Automated tests forthcoming :) but I've at least tried it manually with
our counter and native-fungible examples.

- Nothing to do / These changes follow the usual release cycle.

Breaks SDK API but no need to backport.

- [reviewer
checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
@Twey Twey added the backport This PR backports functionality already available on `main`. label Nov 19, 2025
@Twey
Copy link
Contributor Author

Twey commented Nov 19, 2025

CI was not running on #4984, so hopefully this one will fare better.

Twey added 2 commits November 19, 2025 01:48
Currently all our testing for the Web client is manual. We'd like to
know when PRs break our example apps.

This PR sets up conventions for our Web tests that enable us to test in
a variety of different environments. Going forward we can add more and
more in-depth tests to cover more scenarios, and if we backport this PR
we can also use these tests as an automated healthcheck for the deployed
Web apps.

We unify the Web tests using [Vitest](https://vitest.dev/) with a
[Playwright](https://playwright.dev/) backend to run tests in real
browsers (currently just Chromium, but we should also test at least on
WebKit and Firefox once
linera-io#4235 is fixed).

Add a couple of basic tests for `@linera/client`: getting a wallet from
the faucet and initializing the client.

This is the test plan :)

- These changes should be backported to the latest `testnet` branch,
then
    - be released in a new SDK.

- [reviewer
checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
Our hacked-up version of `wasm_thread` isn't a great fit for our use
cases.

Firstly, `wasm_thread` aims to mimic the API of `std::thread`. This was
never sufficient for us as we need to send non-`Send` messages across
threads actively using `postMessage`, which `std::thread` has no
equivalent for. We patched `wasm_thread` but it was at odds with the
point of the package.

Then, in order to use `wasm_thread` without threading a shim script URL
through the code down into `linera-base`, we dynamically got the URL of
the `wasm-bindgen` shim script using `import.meta.url`. This is poorly
(and inconsistently) supported by bundlers, which want to know what the
URL will be used for; but since the `Worker` construction in
`wasm_thread` is done in Rust code they cannot analyze it. This resulted
in our `@linera/client` library being rather fragile under different
bundlers, with workarounds required to ensure they don't interfere with
the paths of the various files.

Introduce the
[`web-thread`](https://docs.rs/web-thread/latest/web_thread/) library, a
simplified equivalent to `wasm_thread` that has a Web-first API,
including a trait for types that can be passed by `postMessage`
(including [transferable
objects](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Transferable_objects)),
and whose worker logic is primarily implemented in JavaScript, making it
much more comprehensible to bundlers.

This allows us:
- to communicate both `Send` and `Post` objects with long-running
threads, as is required by
linera-io#3651 and eventually
linera-io#2927
- to remove the bundling caveats from Linera documentation
- to support WebPack
- to delete `linera_base::task` and the conditional compilation therein

The `web-thread` library itself has been tested with Vite as well as
WebPack (via Next.js with the `--webpack` flag), and includes example
applications to that effect.

I have manually tested our two Web applications in this repository.

I defer to CI for full tests of the native pathways.

- Nothing to do / These changes follow the usual release cycle.

- Fixes linera-io#2809.
- First step towards
linera-io#3651.
- [`web-thread` docs](https://docs.rs/web-thread/latest/web_thread/)

Turbopack is currently not supported due to an open issue when
processing cyclic dependencies. See the following discussions for more
information:

* vercel/next.js#85119
* vercel/next.js#77102
* emscripten-core/emscripten#20580
@Twey Twey force-pushed the testnet/conway/web-thread branch from 25f5a75 to f11469a Compare November 19, 2025 01:48
@ma2bd
Copy link
Contributor

ma2bd commented Nov 19, 2025

CI was not running on #4984, so hopefully this one will fare better.

This happens when you change the base branch. The solution is to modify a commit and push again.

@Twey Twey marked this pull request as ready for review November 19, 2025 11:22
@Twey Twey requested a review from ma2bd November 19, 2025 15:18
@Twey
Copy link
Contributor Author

Twey commented Nov 19, 2025

Good to know for next time. Though it seems like a bit of an oversight!

@Twey Twey requested a review from deuszx November 19, 2025 15:19
@Twey Twey merged commit 7a9ef14 into linera-io:testnet_conway Nov 19, 2025
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR backports functionality already available on `main`.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants