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

Feature: SSR Shared State #34

Merged
merged 1 commit into from
Jul 18, 2022
Merged

Feature: SSR Shared State #34

merged 1 commit into from
Jul 18, 2022

Conversation

sgammon
Copy link
Member

@sgammon sgammon commented Jul 18, 2022

Ready for review Powered by Pull Request Badge

This changeset introduces the concept of shared state, which is computed during a PageController execution, and shared with the render context.

State is shared with the frontend via an injected JSON blob which the framework can decode on behalf of the developer, similar to how getServerSideProps works in Next.js.

VM-side, state is exported for guest language use, allowing access to context/state within SSR bundles.

Changelog

  • Introduce new PageWithProps controller, and props() extension point, where the developer provides shared state for a given request/response cycle
  • Support basic for state sharing with SSR scripts
  • Serialize and inject server-side props for frontend use
  • Provide boot entrypoint for frontend apps, which accounts for server-injected state, + SSR vs. CSR mode
  • Fix for double-render / double-compute of state
  • Fix support for VM inspection via -Delide.vm.inspect
  • Fix for runBlocking call during HTML rendering
  • Testsuite amendments / fixes
  • General cleanup (quite a mess)

@sgammon sgammon added java Pull requests that update Java code module:graalvm Modules, changes, and issues relating to GraalVM module:server Modules, changes, and issues relating to Elide for servers feature Large PRs or issues with full-blown features 🚧 WIP Works-in-progress. Blocks merge javascript Features and issues relating to JS labels Jul 18, 2022
@sgammon sgammon added this to the Release R1: Alpha 1 milestone Jul 18, 2022
@sgammon sgammon self-assigned this Jul 18, 2022
@sonarcloud
Copy link

sonarcloud bot commented Jul 18, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug C 1 Bug
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

7.9% 7.9% Coverage
0.0% 0.0% Duplication

@codecov
Copy link

codecov bot commented Jul 18, 2022

Codecov Report

Merging #34 (0075e45) into v3 (c5fdf89) will increase coverage by 4.78%.
The diff coverage is 14.51%.

Impacted file tree graph

@@             Coverage Diff              @@
##                 v3      #34      +/-   ##
============================================
+ Coverage     59.02%   63.81%   +4.78%     
- Complexity      350      356       +6     
============================================
  Files            69       70       +1     
  Lines          2726     2556     -170     
  Branches        248      228      -20     
============================================
+ Hits           1609     1631      +22     
+ Misses         1056      862     -194     
- Partials         61       63       +2     
Impacted Files Coverage Δ
...src/main/kotlin/elide/runtime/graalvm/JsRuntime.kt 0.00% <0.00%> (ø)
...alvm/src/main/kotlin/elide/server/SSRExtensions.kt 0.00% <0.00%> (ø)
.../main/kotlin/elide/server/ssr/ServerSSRRenderer.kt 0.00% <0.00%> (ø)
...server/src/main/kotlin/elide/server/Application.kt 0.00% <0.00%> (ø)
...in/kotlin/elide/server/controller/PageWithProps.kt 0.00% <0.00%> (ø)
...ide/server/controller/builtin/BuiltinController.kt 100.00% <ø> (ø)
...rc/main/kotlin/elide/server/runtime/AppExecutor.kt 82.75% <ø> (+25.18%) ⬆️
.../src/main/kotlin/elide/server/type/RequestState.kt 0.00% <0.00%> (ø)
...er/src/main/kotlin/elide/server/util/ServerFlag.kt 0.00% <0.00%> (ø)
...ges/server/src/main/kotlin/kotlinx/html/api.ext.kt 0.00% <0.00%> (ø)
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c5fdf89...0075e45. Read the comment docs.

This changeset introduces the concept of shared state, which is
computed during a `PageController` execution, and shared with the
render context.

State is shared with the frontend via an injected JSON blob which
the framework can decode on behalf of the developer, similar to how
`getServerSideProps` works in Next.js.

VM-side, state is exported for guest language use, allowing access
to context/state within SSR bundles.

Changes enclosed:
- Introduce new `PageWithProps` controller, and `props()` extension
  point, where the developer provides shared state for a given cycle
- Support basic for state sharing with SSR scripts
- Serialize and inject server-side props for frontend use
- Provide `boot` entrypoint for frontend apps, which accounts for
  server-injected state, + SSR vs. CSR mode
- Fix for double-render / double-compute of state
- Fix support for VM inspection via `-Delide.vm.inspect`
- Fix for `runBlocking` call during HTML rendering
@sgammon sgammon marked this pull request as ready for review July 18, 2022 06:46
@sgammon sgammon removed the 🚧 WIP Works-in-progress. Blocks merge label Jul 18, 2022
@sonarcloud
Copy link

sonarcloud bot commented Jul 18, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 4 Code Smells

14.6% 14.6% Coverage
0.0% 0.0% Duplication

@sgammon sgammon merged commit d4975f8 into v3 Jul 18, 2022
@sgammon sgammon deleted the feat/ssr-state branch July 18, 2022 07:10
This was referenced Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Large PRs or issues with full-blown features java Pull requests that update Java code javascript Features and issues relating to JS module:graalvm Modules, changes, and issues relating to GraalVM module:server Modules, changes, and issues relating to Elide for servers
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

1 participant