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

Cookies are missing during lighthouse scan #197

Open
lutejka opened this issue Mar 7, 2024 · 3 comments
Open

Cookies are missing during lighthouse scan #197

lutejka opened this issue Mar 7, 2024 · 3 comments

Comments

@lutejka
Copy link
Contributor

lutejka commented Mar 7, 2024

Describe the bug

I set some cookies in the configuration. During the startup, those cookies are used, however they are missing in the actuall scan.

To heck this, I used the following set up:

server.js

import http from 'http'

function parseCookies (request) {
    const list = {};
    const cookieHeader = request.headers?.cookie;
    if (!cookieHeader) return list;

    cookieHeader.split(`;`).forEach(function(cookie) {
        let [ name, ...rest] = cookie.split(`=`);
        name = name?.trim();
        if (!name) return;
        const value = rest.join(`=`).trim();
        if (!value) return;
        list[name] = decodeURIComponent(value);
    });

    return list;
}

const server = http.createServer(function (request, response) {
    // To Read a Cookie
    const cookies = parseCookies(request);
    console.log(cookies)


    response.writeHeader(200, {"Content-Type": "text/html"});
    response.write('<div>test</div>');
    response.end();
}).listen(8080);

const {address, port} = server.address();
console.log(`Server running at http://${address}:${port}`);

run ´node server.js´

run unlghthouse with the follwoing config

export default {
  site: 'http://localhost:8080',
  cookies: [
    {
      name: 'test',
      value:'2023-07-06T12:01:40.453Z'
    },
  ],
}

In the output of node server.js the used cookies should be logged, but they are missing.

Reproduction

No response

System / Nuxt Info

No response

@harlan-zw
Copy link
Owner

Hi, thanks for providing the reproduction code. I've tried it locally and it seems to be outputting the headers. Can you confirm which version you're using?

@lutejka
Copy link
Contributor Author

lutejka commented Apr 24, 2024

I cant remember it was either 0.10.* or 0.11*. I also just tested it with 0.12.0 and it still happens

image

@lutejka
Copy link
Contributor Author

lutejka commented Apr 24, 2024

When testing a other side I also got these errors a bunch

 ERROR  Failed to set cookies Protocol error (Network.deleteCookies): Target closed                                                                                                                      Unlighthouse 10:38:48 PM

  at CallbackRegistry.clear (/Users/lukas.matejka/.npm/_npx/944abecbf21dfffb/node_modules/puppeteer-core/lib/esm/puppeteer/common/CallbackRegistry.js:69:36)
  at CdpCDPSession._onClosed (/Users/lukas.matejka/.npm/_npx/944abecbf21dfffb/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/CDPSession.js:98:25)
  at Connection.onMessage (/Users/lukas.matejka/.npm/_npx/944abecbf21dfffb/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Connection.js:118:25)
  at Immediate.<anonymous> (/Users/lukas.matejka/.npm/_npx/944abecbf21dfffb/node_modules/puppeteer-core/lib/esm/puppeteer/node/NodeWebSocketTransport.js:37:36)
  at process.processImmediate (node:internal/timers:478:21)

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

2 participants