sveltejs / svelte-devtools

A browser extension to inspect Svelte application by extending your browser devtools capabilities
https://chromewebstore.google.com/detail/svelte-devtools/kfidecgcdjjfpeckbblhmfkhmlgecoff
MIT License
1.46k stars 78 forks source link

Error on macos Chrome - Uncaught TypeError: Cannot read properties of null (reading 'appendChild') #232

Open leafOfTree opened 4 days ago

leafOfTree commented 4 days ago
image

"document.head" is null at the runtime. Not sure if it only occurs on macos. I've created a PR to fix it https://github.com/sveltejs/svelte-devtools/pull/233

Reproduce steps

  1. Open Chrome on macos
  2. Load this extension
  3. Launch a new project created by svelte-kit
  4. Open devtools Svelte tab
  5. Click on reload
  6. See the error in console, Svelte tab is not reloaded

Expected behavior No error, Svelte tab should show components

Environment

ignatiusmb commented 4 days ago

Hey, thanks for reporting this! According to MDN, document.head should never be null, so this might have something to do the chrome.scripting.executeScript() method.

https://github.com/sveltejs/svelte-devtools/blob/09f3ecde5eab7366cea099b839937e194d2344d7/workspace/extension/static/background.js#L59

I did turn on injectImmediately back then but I can't seem to remember what problems I encountered without it. Unfortunately, I don't have any access to any macOS machine, it would be great if you could try turning this setting off and see if the error still occurs. I'll try to check back here after I can verify the expected behaviors

leafOfTree commented 3 days ago

Thanks for your reply. It does work if I turn the setting off.