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

plugin-import-css occasionally processes CSS from <link> tags during development #492

Closed
1 of 5 tasks
thescientist13 opened this issue Mar 21, 2021 · 2 comments · Fixed by #493
Closed
1 of 5 tasks
Assignees
Labels
alpha.9 bug Something isn't working Plugins Greenwood Plugins v0.10.0

Comments

@thescientist13
Copy link
Member

thescientist13 commented Mar 21, 2021

Type of Change

  • New Feature Request
  • Documentation / Website
  • Improvement / Suggestion
  • Bug
  • Other (please clarify below)

Summary

Occasionally during development when running yarn develop and loading the site for the first time, you'll see the site but with broken styles for (what I came to realize) was any CSS loaded via <link> tag (which is not the intended behavior)
develop-broken-styles

Even at the same time....
Screen Shot 2021-03-19 at 4 31 09 PM

Probably related to a recent change to support other import for CSS in other browsers, see #482 / #483 for reference I guess?

Details

Some interesting observations:

  • I could only get to happen when dev tools was closed
  • Only really seemed to happen in Chrome
  • Doesn't happen in Getting Started repo, but does in my website repo (common thread being usage of plugin-import-css)

Was seeing something like this for theme.css

CSS-in-JS intercepting /Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/www/styles/theme.css
CSS-in-JS intercepting headers {
  request: {
    host: 'localhost:1984',
    connection: 'keep-alive',
    'sec-ch-ua': '"Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"',
    'sec-ch-ua-mobile': '?0',
    'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36',
    accept: 'application/signed-exchange;v=b3;q=0.9,*/*;q=0.8',
    purpose: 'prefetch',
    'sec-fetch-site': 'same-origin',
    'sec-fetch-mode': 'no-cors',
    'sec-fetch-dest': 'style',
    referer: 'http://localhost:1984/',
    'accept-encoding': 'gzip, deflate, br',
    'accept-language': 'en-US,en;q=0.9,es;q=0.8,it;q=0.7',
    cookie: '_ga=GA1.1.2112235173.1566163902; _gid=GA1.1.387321566.1616260324'
  },
  response: [Object: null prototype] {
    'content-type': 'text/css',
    'content-length': '922'
  }
}

Probably need some better logic here and maybe should be based on request headers instead?

@thescientist13 thescientist13 added bug Something isn't working Plugins Greenwood Plugins labels Mar 21, 2021
@thescientist13 thescientist13 changed the title **plugin-import-css** occasionally process CSS from <link> tags during development plugin-import-css occasionally process CSS from <link> tags during development Mar 21, 2021
@thescientist13
Copy link
Member Author

thescientist13 commented Mar 21, 2021

So been doing a lot of investigation, but when it happened just now, I was able to capture the headers and noticed something interesting

content type response.header for intercept [Object: null prototype] {
  'content-type': 'text/css',
  'content-length': '922'
}
content type request.header for intercept {
  host: 'localhost:1984',
  connection: 'keep-alive',
  'sec-ch-ua': '"Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"',
  'sec-ch-ua-mobile': '?0',
  'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36',
  accept: 'application/signed-exchange;v=b3;q=0.9,*/*;q=0.8',
  purpose: 'prefetch',
  'sec-fetch-site': 'same-origin',
  'sec-fetch-mode': 'no-cors',
  'sec-fetch-dest': 'style',
  referer: 'http://localhost:1984/',
  'accept-encoding': 'gzip, deflate, br',
  'accept-language': 'en-US,en;q=0.9,es;q=0.8,it;q=0.7',
  cookie: '_ga=GA1.1.2112235173.1566163902; _gid=GA1.1.387321566.1616260324'
}
for url /Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/www/styles/theme.css

The request.accept header value is 'application/signed-exchange;v=b3;q=0.9,*/*;q=0.8??? I have heard of signed exchanges but not sure in this case it would be this value and not the usual text/css?

ex.

content type response.header for intercept [Object: null prototype] {
  'content-type': 'text/css',
  'content-length': '922'
}
content type request.header for intercept {
  host: 'localhost:1984',
  connection: 'keep-alive',
  'sec-ch-ua': '"Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"',
  'sec-ch-ua-mobile': '?0',
  'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36',
  accept: 'text/css,*/*;q=0.1',
  'sec-fetch-site': 'same-origin',
  'sec-fetch-mode': 'no-cors',
  'sec-fetch-dest': 'style',
  referer: 'http://localhost:1984/',
  'accept-encoding': 'gzip, deflate, br',
  'accept-language': 'en-US,en;q=0.9,es;q=0.8,it;q=0.7',
  cookie: '_ga=GA1.1.2112235173.1566163902; _gid=GA1.1.387321566.1616260324'
}
for url /Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/www/styles/theme.css
******************************
final objet contentType text/css
!!!!!!!!!!!!!!!!!!!!!!!!!!!!

@thescientist13 thescientist13 self-assigned this Mar 21, 2021
@thescientist13
Copy link
Member Author

OK, added a bit of hack I guess by just specifically checking for that header, and can now confirm in that edge case where we get application/signed-exchange, it is now working in that edge case.
Screen Shot 2021-03-20 at 8 44 53 PM

Nothing like a curveball bug at that last moment ⚾ ☺️

@thescientist13 thescientist13 linked a pull request Mar 21, 2021 that will close this issue
@thescientist13 thescientist13 changed the title plugin-import-css occasionally process CSS from <link> tags during development plugin-import-css occasionally processes CSS from <link> tags during development Mar 21, 2021
@thescientist13 thescientist13 mentioned this issue Mar 26, 2021
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alpha.9 bug Something isn't working Plugins Greenwood Plugins v0.10.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant