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

Injection happen after page load #1475

Closed
tien opened this issue Nov 11, 2024 · 4 comments · Fixed by #1486
Closed

Injection happen after page load #1475

tien opened this issue Nov 11, 2024 · 4 comments · Fixed by #1486
Labels
Bug Tracks issues causing errors or unintended behavior, critical to fix for reliability. P2 - Medium Important but not urgent. Enhances functionality and value, scheduled after higher priorities.

Comments

@tien
Copy link
Contributor

tien commented Nov 11, 2024

Since injection happen asynchronously after the page have loaded, if you try to detect whether PJS is installed too early, it might appeared that the extension is not installed.

@Tbaut
Copy link
Contributor

Tbaut commented Dec 2, 2024

I noticed it too, and actually had a really nasty piece of code waiting for a sec or 2 before checking again when I handled the connection myself. I've had a user tell me the same on Multix while using dot-connect. I believe it's safer for pjs extension to do so, and I guess dot-connect could probably poll for a couple seconds.

@tien
Copy link
Contributor Author

tien commented Dec 2, 2024

Yeah, polling or delaying is an easy fix. But ideally this should be fixed on PJS extension side, since this is an unexpected behaviour that is unique to PJS extension.

@Tbaut
Copy link
Contributor

Tbaut commented Dec 2, 2024

I guess it comes from there:

if (document.readyState === 'complete') {

it waits for the document to be in "complete" state. I wonder if we should have document.readyState === "loading".
In early code we were injecting in either state complete or interactive, now it rang a bell, and I do recall we had issues explaining why we went for the safer side, I found the comment: #507 (comment)

@TarikGul TarikGul added Bug Tracks issues causing errors or unintended behavior, critical to fix for reliability. P2 - Medium Important but not urgent. Enhances functionality and value, scheduled after higher priorities. labels Dec 3, 2024
@github-project-automation github-project-automation bot moved this from P2 - Medium to Done in Polkadot-js general project board Dec 4, 2024
@polkadot-js-bot
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.

@polkadot-js polkadot-js locked as resolved and limited conversation to collaborators Dec 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Tracks issues causing errors or unintended behavior, critical to fix for reliability. P2 - Medium Important but not urgent. Enhances functionality and value, scheduled after higher priorities.
Development

Successfully merging a pull request may close this issue.

4 participants