Skip to content

Dev Server setServerOptions causes crash during live reload #103

@kingmesal

Description

@kingmesal

Operating system

Linux Mint

Eleventy

3.0.0

Describe the bug

My 11ty build runs great. I put it into serve mode with live reloading, and it works great.

The moment I add an example from this page to add onRequest to the server the problems start.

The server starts just fine pages are served with no problems. If I change any watch files and trigger a page reload the server crashes. If I comment out those lines, all is good again.

[11ty] File changed: /customers/production/tailwind/site/utilities.css
733 |   getServerUrlRaw(host, pathname = "", isRaw = true) {
734 |     if(!this._server || !this._serverProtocol) {
735 |       throw new Error("Access to `serverUrl` property not yet available.");
736 |     }
737 | 
738 |     let { port } = this._server.address();
                                      ^
TypeError: Right side of assignment cannot be destructured
      at getServerUrlRaw (/operations/site-builder/node_modules/@11ty/eleventy-dev-server/server.js:738:33)
      at <anonymous> (/operations/site-builder/node_modules/@11ty/eleventy-dev-server/server.js:460:26)
      at eleventyDevServerMiddleware (/operations/site-builder/node_modules/@11ty/eleventy-dev-server/server.js:453:37)
      at <anonymous> (/operations/site-builder/node_modules/@11ty/eleventy-dev-server/server.js:633:11)
      at onRequestHandler (/operations/site-builder/node_modules/@11ty/eleventy-dev-server/server.js:580:27)
      at emit (node:events:90:22)
      at fetch (node:http:400:24)

Reproduction steps

No response

Expected behavior

It shouldn't crash and it should reload without fail.

Reproduction URL

No response

Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions