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

In BlazorSSR running in AWS Lambda Dotnet, OnInitializedAsync gets called twice #67

Open
genifycom opened this issue Sep 20, 2024 · 2 comments

Comments

@genifycom
Copy link

Hi Egil,

I know this is not mainstream for you, but you might be able to tell me where to look.

Using the AWS Lambda Application template combined with the Blazor Web App SSR (Interaction type None) I get the following behavior.

On the Weather.razor page.

  1. Without any HTMX parts, OnInitializedAsync gets called once.
  2. Just adding .AddHtmx(); to services causes OnInitializedAsync to be called once if used in the URL e.g. https://localhost:64219/weather but called twice if called from the NavMenu.

This has nothing to do with pre-rendering (which the web is full of info on) since this is Interaction type None and calls none of the interactive parts.

I suspect it is to do with the internal rendering of components by Htmxor.

Any suggestions on how to trace it?

@egil
Copy link
Owner

egil commented Sep 20, 2024

Hey, no worries, if you can share a minimal repro of the issue you are seeing I can try to run it locally and see if I can figure it out.

@genifycom
Copy link
Author

AWSServerlessHtmxor.zip

Hi Egil,

Here is the project. The Project template was created using the AWS Toolkit https://aws.amazon.com/visualstudio/
It is a Serverless Application

To run it locally, you will need the AWS Mock Lamda tool
https://github.com/aws/aws-lambda-dotnet/tree/master/Tools/LambdaTestTool

Once you have this, you start the application normally.

I used the components folder from Blazor Web App and in startup, the Blazor Component requirements were added.

Then I added Htmxor Nuget preview.

In startup line 18, is the normal services.AddRazorComponents(); and the Weather.razor page runs with a single call to OnInitializedAsync (breakpoint at Weather.razor line 45).

If you then comment out Startup line 18 and uncomment line 21 and run again, this time the Weather.razor page runs with a two calls to OnInitializedAsync (breakpoint at Weather.razor line 45).

I hope you can get this running easily.

Thank you,
Dave

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

No branches or pull requests

2 participants