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

Double execution of the page on the server side, at server startup, when the page is open in a web browser #6910

Closed
lukaszpolowczyk opened this issue Sep 20, 2022 · 1 comment · Fixed by #9933
Labels
Milestone

Comments

@lukaszpolowczyk
Copy link
Contributor

Describe the bug

Double execution of the page on the server side, at server startup, when the page is open in a web browser.

Reproduction

  1. use the repo https://github.com/lukaszpolowczyk/podwojnelogi
  2. install
  3. fire up the server
  4. open the page in a web browser
  5. stop the server
  6. clean the terminal
  7. fire up the server again

You will see a double log from src/routes/+page.svelte in the terminal:

test page.svelte
test page.svelte

When the page is not open in the browser, the log is only one, when firing up the server

Why does it work this way? Is this how it should work?

Logs

No response

System Info

System:
    OS: Linux 5.10 Arch Linux
    CPU: (4) x64 AMD Athlon(tm) X4 950 Quad Core Processor
    Memory: 6.52 GB / 15.07 GB
    Container: Yes
    Shell: 5.1.8 - /bin/bash
  Binaries:
    Node: 18.4.0 - ~/.nvm/versions/node/v18.4.0/bin/node
    Yarn: 1.22.10 - /usr/bin/yarn
    npm: 8.12.1 - ~/.nvm/versions/node/v18.4.0/bin/npm
  Browsers:
    Brave Browser: 100.1.37.109
    Firefox: 102.2.0esr
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.76 
    @sveltejs/kit: next => 1.0.0-next.489 
    svelte: ^3.46.0 => 3.50.1 
    vite: ^3.1.0 => 3.1.3

Severity

annoyance

Additional Information

No response

@Rich-Harris
Copy link
Member

If I add some logging to a load function in src/routes/+page.server.js...

export function load({ request }) {
  console.log(request.method, Object.fromEntries(request.headers));
}

...I see this:

GET {
  accept: '*/*',
  'accept-encoding': 'gzip, deflate, br',
  'accept-language': 'en-US,en;q=0.5',
  connection: 'keep-alive',
  cookie: 'userid=e8c7c84e-c4bf-44f8-809e-2cfa1e45faf3; name=SvelteKit',
  dnt: '1',
  host: 'localhost:5173',
  'if-none-match': '"1iy0ruo"',
  referer: 'http://localhost:5173/',
  'sec-fetch-dest': 'empty',
  'sec-fetch-mode': 'no-cors',
  'sec-fetch-site': 'same-origin',
  'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:104.0) Gecko/20100101 Firefox/104.0'
}
test page.svelte
GET {
  accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
  'accept-encoding': 'gzip, deflate, br',
  'accept-language': 'en-US,en;q=0.5',
  connection: 'keep-alive',
  cookie: 'userid=e8c7c84e-c4bf-44f8-809e-2cfa1e45faf3; name=SvelteKit',
  dnt: '1',
  host: 'localhost:5173',
  'if-none-match': '"1iy0ruo"',
  'sec-fetch-dest': 'document',
  'sec-fetch-mode': 'navigate',
  'sec-fetch-site': 'cross-site',
  'upgrade-insecure-requests': '1',
  'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:104.0) Gecko/20100101 Firefox/104.0'
}
test page.svelte

I believe the first request is coming from the Vite HMR client, though it's difficult to be sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants