Skip to content

Error when hot reloading preloaded stylesheet link #682

Closed
@cdoublev

Description

@cdoublev
  • Operating System: Debian Buster (Virtual Machine)
  • Node Version: 15.5.0
  • NPM Version: 7.3.0
  • webpack Version: 5.17.0
  • mini-css-extract-plugin Version: 1.3.4

Expected Behavior

The updated <link rel="preload stylesheet" ...> should be replaced (hot reloaded) without throwing error.

I'm not sure that a preload stylesheet link should emit a load event twice, but it happens in Chrome and Firefox. I didn't tested in other browsers.

Actual Behavior

The following error is thrown in Chrome:

Uncaught TypeError: Cannot read property 'removeChild' of null
    at HTMLLinkElement.eval (hotModuleReplacement.js:105)

The following error is thrown in Firefox:

Uncaught TypeError: el.parentNode is null
    updateCss webpack://mini-css-extract-plugin-issue/./node_modules/mini-css-extract-plugin/dist/hmr/hotModuleReplacement.js?:105
    [...]

Code

https://github.com/cdoublev/mini-css-issue

How Do We Reproduce?

Clone above repository.
Run webpack serve.
Open browser at localhost.
Update src/style.css.
Check error in the browser console.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions