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

Bug when using exec only after version 0.11.18 #1292

Closed
markwylde opened this issue May 16, 2021 · 1 comment
Closed

Bug when using exec only after version 0.11.18 #1292

markwylde opened this issue May 16, 2021 · 1 comment

Comments

@markwylde
Copy link

markwylde commented May 16, 2021

I have come across a very strange issue.

I have the following build script:

const esbuild = require('esbuild');

const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))

async function buildJs () {
  await sleep(1);

  return esbuild.build({
    entryPoints: ['./src/js/index.js'],
    outfile: './public/index.min.js',
    bundle: true,
    minify: true
  });
}

async function buildCss () {
  return esbuild.build({
    entryPoints: ['./src/css/index.css'],
    bundle: true,
    outfile: './public/style.min.css'
  });
}

buildJs()
buildCss()

This works totally fine in 0.11.18, but breaks in the latest version.

If I comment out the line await sleep(1);, then it works fine in the new version.

Example repository

I have included the example repository below. If you clone it and run it, everything works fine. Then upgrade esbuild, and it will break.
https://github.com/markwylde/esbuild-exec-bug

I've tried for the whole day to narrow this down, but I just don't know why it's happening.

** Broken (version 0.11.19 or higher)
broken

** Working (version 0.11.18)
working

Node Versions

I've tested this on multiple versions of node, all with the same results:

  • v12.20.1
  • v14.17.0
  • v16.1.0

Edits:

  1. I was originally doing an exec, but it's nothing to do with that. It looks like anything async breaks it
  2. I simplified the code to remove the outer async function
@evanw
Copy link
Owner

evanw commented May 16, 2021

Thanks for the report. This is happening because the internal helper functions are parsed once and cached per configuration, but the new profiler name option that was added in version 0.11.19 was accidentally not included in the cache key. It's strange that this didn't show up in tests. I'll fix this in the next release.

@evanw evanw closed this as completed in 29ea70a May 16, 2021
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