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

Windi Analysis throws H3 Warnings when using with Nuxt 3 RC13 #187

Closed
AndrewBogdanovTSS opened this issue Nov 6, 2022 · 9 comments
Closed

Comments

@AndrewBogdanovTSS
Copy link

Describe the bug
Warnings in terminal after upgrading to Nuxt RC 13

 WARN  [h3] Implicit event handler conversion is deprecated. Use eventHandler() or fromNodeMi
ddleware() to define event handlers.
     Route: /api
     Handler: async (req, res, next) => {
    if (!req.url)
      return next();
    const fullpath = req.url;
    const [path, queryString = ""] = fullpath.split("?", 2);
    const query = new URLSearchParams(queryString);
    if (path === "/report.json") {
      if (!analysisReturn || query.has("force"))
        analysisReturn = await runAnalysis(windicssOptions, analysisOptions);
      res.write(JSON.stringify(analysisReturn.result));
      return res.end();
    } else if (path === "/interpret") {
      if (!analysisReturn)
        analysisReturn = await runAnalysis(windicssOptions, analysisOptions);
      const name = query.get("name") || "";
      res.write(analysisReturn.utils.processor.interpret(name).styleSheet.build());
      return res.end();
    } else if (path === "/read") {
      const filepath = query.get("path");
      if (!filepath || !_fs.existsSync.call(void 0, filepath)) {
        res.statusCode = 404;
        return res.end();
      }
      try {
        res.write(await _fs.promises.readFile(filepath, "utf-8"));
        return res.end();
      } catch (e) {
        console.error(e);
        res.statusCode = 500;
        return res.end();
      }
    }
    res.statusCode = 404;
    res.end();
  }


 WARN  [h3] Implicit event handler conversion is deprecated. Use eventHandler() or fromNodeMi
ddleware() to define event handlers.  
     Handler: function (req, res, next) {
                let extns = [''];
                let pathname = parse(req).pathname;
                let val = req.headers['accept-encoding'] || '';
                if (gzips && val.includes('gzip')) extns.unshift(...gzips);
                if (brots && /(br|brotli)/i.test(val)) extns.unshift(...brots);
                extns.push(...extensions); // [...br, ...gz, orig, ...exts]

                if (pathname.indexOf('%') !== -1) {
                        try { pathname = decodeURIComponent(pathname) }
                        catch (err) { /* malform uri */ }
                }

                let data = lookup(pathname, extns) || isSPA && !isMatch(pathname, ignores) &&
 lookup(fallback, extns);
                if (!data) return next ? next() : isNotFound(req, res);

                if (isEtag && req.headers['if-none-match'] === data.headers['ETag']) {       
                        res.writeHead(304);
                        return res.end();
                }

                if (gzips || brots) {
                        res.setHeader('Vary', 'Accept-Encoding');
                }

                setHeaders(res, pathname, data.stats);
                send(req, res, data.abs, data.stats, data.headers);
        }

To Reproduce
Steps to reproduce the behavior:

  1. Install Nuxt 3 RC13
  2. Run pnpm dev
  3. See warnings
  4. Analyzer doesn't start

Expected behavior
No warnings in the console, the analyzer works as expected

Additional context

  • Operating System: Windows_NT
  • Node Version: v19.0.1
  • Nuxt Version: 3.0.0-rc.13
  • Nitro Version: 0.6.1
  • Package Manager: [email protected]
  • Builder: vite |t
  • User Config: alias, extends, vite
  • Runtime Modules: -
  • Build Modules: -

@mgl-pub
Copy link

mgl-pub commented Nov 8, 2022

i have got same problems ~!

@howbizarre
Copy link

howbizarre commented Nov 8, 2022

I have the same problem. It comes from analyze feature.
Set to false in nuxt.config and will stop warning you for now.

This is not a solution, just removes the distraction.

export default defineNuxtConfig({
    modules: ["nuxt-windicss"],
    windicss: {
        analyze: false
    }
});

@AndrewBogdanovTSS
Copy link
Author

@howbizarre yes, it's clear that disabling analyzer will hide warnings, but that doesn't solve the issue, analyzer is a crucial feature that should work with Nuxt

@viandwi24
Copy link

i got same warning when upgrade 2.5.2 to 2.5.3, so im try to downgrade again to 2.5.2 and warning not show again.

@AndrewBogdanovTSS
Copy link
Author

It's very interesting since 2.5.3 release was very minimal, it only adds watch check, I wonder how it may trigger those warnings 🤔

@AndrewBogdanovTSS
Copy link
Author

@viandwi24 I downgraded to v.2.5.2 and got even worse error
[unhandledRejection] Cannot read properties of undefined (reading 'push')
I don't know why downgrade worked for you, as I noticed above - there were nothing specific added in 2.5.3 that could introduce such regression
image

@viandwi24
Copy link

i use nuxt rc13 for that.

this is my repo
https://github.com/viandwi24/nuxt3-awesome-starter

@AndrewBogdanovTSS
Copy link
Author

@viandwi24 I checked your repo and though I don't see warnings in terminal, windi analysis is broken there as well and doesn't load in the browser.
@harlan-zw btw, when running analysis separately from main nuxt process everything works well, so it's definitely a Nitro conflict

@harlan-zw
Copy link
Member

Thanks for the issue @AndrewBogdanovTSS. A fix is released with 2.5.4

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

5 participants