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

[next.180] Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'target.querySelector') #12390

Closed
pheuter opened this issue Jul 10, 2024 · 4 comments

Comments

@pheuter
Copy link

pheuter commented Jul 10, 2024

Describe the bug

Apologies in advance for the suboptimal repro, just started noticing this error and rendering issue when doing a client-side navigate to a page that renders <Select> from the svelte-select lib (ships its own CSS). When doing an SSR while on the target page, there is no error, so it appears to only happen when doing a client-side navigate from a page that doesn't render <Select> to a page that does.

Reproduction

image

Logs

No response

System Info

System:
    OS: macOS 15.0
    CPU: (16) arm64 Apple M3 Max
    Memory: 2.10 GB / 48.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.15.1 - ~/.nvm/versions/node/v20.15.1/bin/node
    npm: 10.8.1 - ~/.nvm/versions/node/v20.15.1/bin/npm
    bun: 1.1.15 - ~/.bun/bin/bun
  Browsers:
    Chrome: 126.0.6478.127
    Safari: 18.0
  npmPackages:
    svelte: ^5.0.0-next.1 => 5.0.0-next.180

Severity

blocking an upgrade

@dummdidumm
Copy link
Member

Does this happen in earlier versions as well or did it start with 180?

@pheuter
Copy link
Author

pheuter commented Jul 10, 2024

next.179 did not have this specific issue for me. More precisely, I had a similar issue with next.179 when hmr was enabled, but it didn't affect me after I turned it off. Now, i have this issue regardless of whether hmr is enabled.

@CaptainCodeman
Copy link

CaptainCodeman commented Jul 12, 2024

Just updated to .182 and started seeing the same thing, this is the block of code it fails on:

// node_modules/.pnpm/[email protected]/node_modules/svelte/src/internal/client/dom/css.js
var seen = /* @__PURE__ */ new Set();
function append_styles(anchor, css) {
  if (!DEV) {
    if (seen.has(css)) return;
    seen.add(css);
  }
  queue_micro_task(() => {
    var root = anchor.getRootNode();
    var target = (
      /** @type {ShadowRoot} */
      root.host ? (
        /** @type {ShadowRoot} */
        root
      ) : (
        /** @type {Document} */
        root.head
      )
    );
    if (!target.querySelector("#"   css.hash)) { // <--- HERE
      const style = document.createElement("style");
      style.id = css.hash;
      style.textContent = css.code;
      target.appendChild(style);
    }
  });
}

Also works if rolled back to .179

@dummdidumm
Copy link
Member

Should be fixed in the latest version.

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

3 participants