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

Did you forget to signal async completion... #245

Open
DenisLopatin opened this issue Mar 16, 2022 · 5 comments
Open

Did you forget to signal async completion... #245

DenisLopatin opened this issue Mar 16, 2022 · 5 comments

Comments

@DenisLopatin
Copy link

{
  ...
  "devDependencies": {
    "@babel/preset-env": "^7.16.11",
    "@babel/register": "^7.17.7",
    "babel-loader": "^8.2.3",
    "gulp": "^4.0.2",
    "gulp-autoprefixer": "^8.0.0",
    "gulp-concat": "^2.6.1",
    "gulp-cssmin": "^0.2.0",
    "gulp-rename": "^2.0.0",
    "gulp-sourcemaps": "^3.0.0",
    "gulp-typescript": "^6.0.0-alpha.1",
    "prettier": "^2.5.1",
    "ts-loader": "^9.2.8",
    "tslint": "^6.1.3",
    "typescript": "^4.6.2",
    "webpack-stream": "^7.0.0"
  }
}
import {src, dest,} from 'gulp';
import webpack from 'webpack-stream';
import rename from 'gulp-rename';

function scripts() {
    return src("javascript/main.js")
        .pipe(
            webpack({
                output: {
                    filename: "bundle.js",
                },
                devtool: "inline-source-map",
                module: {
                    rules: [
                        {
                            test: /\.m?js$/,
                            exclude: /(node_modules|bower_components|vendor)/,
                            use: {
                                loader: "babel-loader",
                                options: {
                                    presets: ["@babel/preset-env"],
                                },
                            },
                        },
                        {
                            test: /\.tsx?$/,
                            use: "ts-loader",
                            exclude: /node_modules/,
                        },
                    ],
                },
                resolve: {
                    extensions: [".ts", ".js"],
                },
                mode: "development",
            })
        )
        .on("error", (err) => console.error(err))
        .pipe(dest("public/scripts"));
}

export {scripts};

Everything worked yesterday, today I get the following error:

Did you forget to signal async completion

What I did:

  1. These tips didn't help: first, second
  2. I tried using async before scripts function and I did it with @babel/polyfill, but it didn't help me. Fallowing example don't work:
async function scripts() {
   ...

async function scripts() {
   await src("javascript/main.js")
   ...

function scripts(done) {
    src("javascript/main.js")
   ...
   done();

etc...

It worked yesterday!!! But don't work today. I special download my first commit (I did this when everything was working well) and
it doesn't work too!!!

One day has passed, and everything has already broken...

File structure:

-javascript (entree)
-public/scripts/ (output)

Thanks!

@jpgcodecr
Copy link

I'm having the exact same issue, by chance were you able to find a workaround?

@DenisLopatin
Copy link
Author

@jpgcodecr yes I could, I started using webpack for scripts build xd. I really don't understand what happened

@gumby0q
Copy link

gumby0q commented Aug 8, 2022

Hi,
have the same thing but with error handling.

const stream2 = gulp.src([
    './src/js/index.js',
  ])
      .pipe(webpack(
          config,
          compiler,
          function (err, stats) {
            console.log('webpack stats');
            console.log('test error', err);
            /* Use stats to do more things if needed */
          })
          .on('error', function (err) {
            if (buildArgs.env === 'production') {
              console.error("stop build!!!");
            } else {
              console.error("DO NOT stop build!!!");
              this.emit('end'); // Don't stop the rest of the task
            }
          })

it seems that events aka this.emit('end') do not work on node >= 14

@jmcphers
Copy link

jmcphers commented Nov 1, 2022

FWIW, I also hit this error and it was infuriating to debug. It turned out to be due to this code:

webpack-stream/index.js

Lines 258 to 266 in 35b771e

// If entry point manually specified, trigger that
const hasEntry = Array.isArray(config)
? config.some(function (c) { return c.entry; })
: config.entry;
if (hasEntry) {
stream.end();
}
return stream;

In particular, webpack-stream doesn't end the stream unless the webpack config has an entry point defined. Mine didn't (my fault), so the stream was never closed and this eventually caused the async to never complete.

Fix: define an entry in the webpack config.

@someguy20336
Copy link

I just ran into this as well and I cannot figure out what is going on. It isn't the lack of entry, as I have that defined.

I am trying to upgrade from node 16 (webpack-stream v5.2.1) to node 18 (webpack-stream v7). It works on v5, but I get this error on v7 and nothing is generated.

I tried the bare minimum configuration - a single typescript file in entry and ts-loader. Still doesn't signal completion.

Running webpack from the webpack cli works, so it isn't something with my config or webpack itself.

I have no idea how to debug this to give you any more information, but if you have ideas let me know. Probably will end up not using it anymore if we can't get it figured out here, given webpack cli itself works. Would really love to not have to rewrite my gulpfile though.

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