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

feat: add Helia Angular example #309

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

Conversation

paschal533
Copy link

I added how to implement helia in an Angular project

Copy link

vercel bot commented Aug 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
verified-fetch ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 10, 2024 2:22pm

Copy link
Contributor

@SgtPooki SgtPooki left a comment

Choose a reason for hiding this comment

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

I tried running this locally and the page ends up crashing after a few seconds.. the only errors I see are webtransport errors.. I will have to dive into this a bit further

examples/helia-angular/.editorconfig Outdated Show resolved Hide resolved
examples/helia-angular/README.md Outdated Show resolved Hide resolved
examples/helia-angular/src/app/app.component.css Outdated Show resolved Hide resolved
examples/helia-angular/src/app/app.component.html Outdated Show resolved Hide resolved
examples/helia-angular/src/styles.css Show resolved Hide resolved
@achingbrain achingbrain changed the title Feat:Helia Angular example added feat: Helia Angular example added Oct 7, 2024
@achingbrain achingbrain changed the title feat: Helia Angular example added feat: add Helia Angular example Oct 7, 2024
@achingbrain
Copy link
Contributor

@paschal533 thanks so much for opening this - do you have some time to address @SgtPooki's review comments?

@paschal533
Copy link
Author

@paschal533 thanks so much for opening this - do you have some time to address @SgtPooki's review comments?

I totally forgot 🤦. Let me work on it right away. Thank you so much.

@paschal533
Copy link
Author

@SgtPooki Thank you for taking the time to review this pull request and providing such insightful suggestions. The necessary changes have been made accordingly.

@SgtPooki
Copy link
Contributor

I tested this locally again and tried making some improvements, but no matter what I do Chrome will crash the page for some reason. I am thinking it's the WebTransport errors because it doesn't happen in FF

@paschal533
Copy link
Author

I tested this locally again and tried making some improvements, but no matter what I do Chrome will crash the page for some reason. I am thinking it's the WebTransport errors because it doesn't happen in FF

Hi @SgtPooki, Do you have any idea how we can fix the Browser crashing issue? I tried everything I could but Chrome kept crashing.

@SgtPooki
Copy link
Contributor

I tested this locally again and tried making some improvements, but no matter what I do Chrome will crash the page for some reason. I am thinking it's the WebTransport errors because it doesn't happen in FF

Hi @SgtPooki, Do you have any idea how we can fix the Browser crashing issue? I tried everything I could but Chrome kept crashing.

I think we need to see if disabling webtransport fixes the issue in chrome? Angular seems to be doing something odd with network errors, instead of handling them gracefully, and only chromium based browsers throws those errors

@paschal533
Copy link
Author

I tested this locally again and tried making some improvements, but no matter what I do Chrome will crash the page for some reason. I am thinking it's the WebTransport errors because it doesn't happen in FF

Hi @SgtPooki, Do you have any idea how we can fix the Browser crashing issue? I tried everything I could but Chrome kept crashing.

I think we need to see if disabling webtransport fixes the issue in chrome? Angular seems to be doing something odd with network errors, instead of handling them gracefully, and only chromium based browsers throws those errors

Hi @SgtPooki,

Thanks for the suggestion! I'll test disabling WebTransport to see if it resolves the issue in Chrome. I’ll also look into how Angular is handling network errors and try to identify why Chromium-based browsers are throwing these exceptions.

If you have any specific steps or resources for debugging this further, I'd appreciate the pointers. I'll update you once I have some results from the testing.

Thanks again for the help!

@SgtPooki
Copy link
Contributor

If you have any specific steps or resources for debugging this further, I'd appreciate the pointers. I'll update you once I have some results from the testing.

I really wish I did.. I tried stepping through and tracing and couldn't get the app to be accessible in the browser at any point after it crashes. The only other thing I tried doing was building a static front-end so the ng build wasn't playing a part at all, but I just got the same issue.

I think if we can pull out any of the server side stuff here and just use Angular as a front-end library (can Angular even do that? How do you build a fully encapsulated static front-end site with Angular?), it might give us some more insight.

I also tried completely removing the Helia instance from all Angular references to see if that helped, and it did not.

@paschal533
Copy link
Author

paschal533 commented Nov 27, 2024

If you have any specific steps or resources for debugging this further, I'd appreciate the pointers. I'll update you once I have some results from the testing.

I really wish I did.. I tried stepping through and tracing and couldn't get the app to be accessible in the browser at any point after it crashes. The only other thing I tried doing was building a static front-end so the ng build wasn't playing a part at all, but I just got the same issue.

I think if we can pull out any of the server side stuff here and just use Angular as a front-end library (can Angular even do that? How do you build a fully encapsulated static front-end site with Angular?), it might give us some more insight.

I also tried completely removing the Helia instance from all Angular references to see if that helped, and it did not.

Hi @SgtPooki ,

Thanks for sharing your experience! It’s helpful to know you tried building a static front-end and removing Helia references, but the issue persisted.

Regarding your question, yes, Angular can be used as a fully encapsulated static front-end framework. The ng build command produces static files (HTML, CSS, JS) that can be served by any HTTP server. To isolate the problem further, I could try creating a minimal Angular project, removing all server-side interactions, and integrating only Helia with basic functionality. This might help us pinpoint whether it’s Angular itself, the Helia integration, or a Chromium-specific issue.

Here’s what I plan to test next:

  1. Isolated Helia Integration: Build a minimal Angular app with only the Helia instance and no server-side dependencies.
  2. Static Build Deployment: Deploy the static files (ng build) on a simple static server (e.g., serve, http-server) to see if the build process is contributing to the crash.
  3. WebTransport Isolation: Disable WebTransport in the Helia configuration (if possible) or force an alternate transport method.

I’ll let you know what I find. If there’s anything specific you’d like me to test, please let me know!

@paschal533
Copy link
Author

Hi @SgtPooki ,

I managed to resolve the browser crashing issue by isolating Helia in a minimal Angular app. Here’s what I did:

  1. Created a fresh Angular app with no server-side dependencies or additional libraries.
  2. Integrated only Helia with basic initialization in the app.component.ts file.
  3. Ran the app using ng serve and observed that it worked fine without any crashes.

It seems the issue may be related to how Helia interacts with more complex Angular projects or specific configurations.

Let me know your thoughts!

@SgtPooki
Copy link
Contributor

I feel like an example showing how to get it working with server side components would be good but if we have a simple example with just front-end angular working that's a great starting point. Maybe we can change the name to frontend only?

...or, since we confirmed its something with the server side parts of angular, can we encapsulate the Helia component enough to tell the angular build system to only do the helia stuff on the frontend? In react and nextjs this would just be a simple useEffect() IIRC

@paschal533
Copy link
Author

paschal533 commented Nov 28, 2024

I feel like an example showing how to get it working with server side components would be good but if we have a simple example with just front-end angular working that's a great starting point. Maybe we can change the name to frontend only?

...or, since we confirmed its something with the server side parts of angular, can we encapsulate the Helia component enough to tell the angular build system to only do the helia stuff on the frontend? In react and nextjs this would just be a simple useEffect() IIRC

I agree, having an example that shows how to get it working with server side components would be helpful.

Encapsulating Helia to run only on the front-end within Angular is a great idea. While Angular doesn’t have a useEffect() equivalent, we can achieve something similar by:

  1. Checking the platform at runtime to ensure Helia is only initialized in the browser (e.g., using isPlatformBrowser from Angular's @angular/common).
  2. Wrapping Helia initialization inside Angular's ngOnInit() lifecycle hook, which runs only after the component is loaded in the browser.

I'll create an updated version of the example to demonstrate this approach and test it in a more complex Angular setup. I'll also explore encapsulating Helia in a service or module to make it reusable and easier to integrate with server-side rendering or Angular Universal.

@paschal533
Copy link
Author

Hi @SgtPooki,

I wanted to let you know that everything is working now! 🎉 It took me a few days of trial and error to figure it out, but I finally got it sorted. I learned a lot along the way, and honestly, I enjoyed the journey—it was a great challenge!

I’ve pushed the code for review. Let me know if there’s anything else I can improve or adjust.

Thanks for all your guidance and support throughout this process! 🙌

@SgtPooki SgtPooki self-requested a review December 3, 2024 15:33
Copy link
Contributor

@SgtPooki SgtPooki left a comment

Choose a reason for hiding this comment

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

@paschal533 I've confirmed this is working in chrome now (FF still works). Great work!!

There are still a few unresolved issues from previous comments:

  • .editorconfig not idiomatic in these examples (please delete it from the git repo git rm --cached .editorconfig)
  • styling of the page should more closely match styling of other examples

examples/helia-angular/.editorconfig Outdated Show resolved Hide resolved
@paschal533
Copy link
Author

@paschal533 I've confirmed this is working in chrome now (FF still works). Great work!!

There are still a few unresolved issues from previous comments:

  • .editorconfig not idiomatic in these examples (please delete it from the git repo git rm --cached .editorconfig)
  • styling of the page should more closely match styling of other examples

Hi @SgtPooki
Thanks for confirming it works in Chrome and FF!
I've removed the .editorconfig file from the repo as requested. Regarding the styling, I based it on the Next.js example. Could you share specific points or details about how it should align better with the other examples? I'm happy to adjust it!

@SgtPooki
Copy link
Contributor

SgtPooki commented Dec 5, 2024

@paschal533 I see that the nextjs example is using a pretty standard nextjs app template. I am good with leaving this and will chat about this in Helia WG today

@paschal533
Copy link
Author

paschal533 commented Dec 5, 2024

@paschal533 I see that the nextjs example is using a pretty standard nextjs app template. I am good with leaving this and will chat about this in Helia WG today

Alright, thanks @SgtPooki. Please, can you help me with the link to Helia WG today. I can't seem to find it on my calendar. :)

@SgtPooki
Copy link
Contributor

SgtPooki commented Dec 5, 2024

Alright, thanks @SgtPooki. Please, can you help me with the link to Helia WG today. I can't seem to find it on my calendar. :)

you can find all Helia WG meetings on the IPFS calendar here: https://lu.ma/ipfs

Today's meeting is at https://lu.ma/8yw69b08

@paschal533
Copy link
Author

Alright, thanks @SgtPooki. Please, can you help me with the link to Helia WG today. I can't seem to find it on my calendar. :)

you can find all Helia WG meetings on the IPFS calendar here: https://lu.ma/ipfs

Today's meeting is at https://lu.ma/8yw69b08

Thank you.

@paschal533
Copy link
Author

Hi @SgtPooki, I have updated the ci.yml file.

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.

3 participants