question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`fly.clear` is executed early / not awaited

See original GitHub issue

versions:

Platform: Arch Linux 4.6.5-1-zen x86_64 latest Node: v6.4.0 Fly version: 1.3.1

It’s a little hard to describe the issue. First of all, I will explain what the sample contains. And then I describe the operations and what’s weird.

sample project

The repo is here: https://github.com/frantic1048/fly-issue-193

overall sturcture:

.
β”œβ”€β”€ dist            // output path
β”œβ”€β”€ flyfile.js
β”œβ”€β”€ node_modules
β”œβ”€β”€ package.json
└── src             // source path
    β”œβ”€β”€ a
    β”‚   β”œβ”€β”€ a1.txt
    β”‚   β”œβ”€β”€ a2.txt
    β”‚   β”œβ”€β”€ a3.txt
    β”‚   └── a4.txt
    └── b
        β”œβ”€β”€ b1.txt
        β”œβ”€β”€ b2.txt
        β”œβ”€β”€ b3.txt
        └── b4.txt

flyfile.js : just some copy/paste tasks and a clean task, and two top-level task to run tasks in serial/parallel.

const paths = {
  a: {
    source: 'src/a/*.txt',
    target: 'dist/a'
  },
  b: {
    source: 'src/b/*.txt',
    target: 'dist/b'
  },
  all: {target: 'dist'}
}

exports.clean = function * () {
  yield this.clear(paths.all.target)
}

exports.a = function * () {
  yield this
    .source(paths.a.source)
    .target(paths.a.target)
}

exports.b = function * () {
  yield this
    .source(paths.b.source)
    .target(paths.b.target)
}

exports.serial = function * () {
  yield this.start('clean')
  yield this.start('a')
  yield this.start('b')
}

exports.parallel = function * () {
  yield this.start('clean')
  yield this.start(['a', 'b'], {parallel: true})
}

package.json : the only dependency is fly, just npm i to install it.

{
  "name": "fly-missing-file",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "cc": "fly clean",
    "s": "DEBUG=\"fly*\" fly serial",
    "p": "DEBUG=\"fly*\" fly parallel"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "fly": "^1.3.1"
  }
}

.txt : every .txt file is just Lorem ipsum . Other content also is ok.

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam, iste, iure, quod voluptates soluta quidem commodi animi recusandae unde obcaecati amet eaque facere similique. Necessitatibus, iusto possimus minima numquam modi.

reproducing operation

Ensure you have runned npm install to get the dependencies ready.

Now, the dist folder is empty, we run paralleled task.

npm run p

Then dist becomes:

dist/
β”œβ”€β”€ a
β”‚   β”œβ”€β”€ a1.txt
β”‚   β”œβ”€β”€ a2.txt
β”‚   β”œβ”€β”€ a3.txt
β”‚   └── a4.txt
└── b
    β”œβ”€β”€ b1.txt
    β”œβ”€β”€ b2.txt
    β”œβ”€β”€ b3.txt
    └── b4.txt

Every thing works great. Then we run the paralled task the second time.

npm run p

Then whole dist disappeared, even the dist folder itself. While debug log shows all the *.txt were written.

We can type npm run p again, then all the files are back. This time we delete some of the output file:

dist/
β”œβ”€β”€ a
β”‚   β”œβ”€β”€ a1.txt
β”‚   └── a2.txt
└── b
    └── b4.txt

Then type npm run p, we get:

dist/
β”œβ”€β”€ a
β”‚   β”œβ”€β”€ a3.txt
β”‚   └── a4.txt
└── b
    β”œβ”€β”€ b1.txt
    β”œβ”€β”€ b2.txt
    └── b3.txt

It just like all the output are β€œinverted”, this situation also happens replacing all the npm run p by npm run s(serial version).

And every time running npm run p, the debug log shows every output file was written, log like:

[frantic@RabbitHouseCafe fly-missing-file]$ npm run p

> fly-missing-file@1.0.0 p /home/frantic/work/demoo/fly-missing-file
> DEBUG="fly*" fly parallel

  fly:find find this file: flyfile.js +0ms
  fly:plugins beginning to look for plugins +5ms
  fly:find find this file: package.json +1ms
  fly:read read this file: /home/frantic/work/demoo/fly-missing-file/package.json +0ms
  fly:plugins parse fly-* plugins from `package.json` +2ms
  fly chdir '/home/frantic/work/demoo/fly-missing-file' +1ms
  fly:log Flying with /home/frantic/work/demoo/fly-missing-file/flyfile.js... +2ms
  fly start [ 'parallel' ] in sequence +0ms
  fly run 'parallel' +2ms
  fly:log Starting parallel +0ms
  fly start [ 'clean' ] in sequence +0ms
  fly run 'clean' +0ms
  fly:log Starting clean +0ms
  fly clear [ 'dist' ] +0ms
  fly:log Finished clean in 4 ms +4ms
  fly start [ 'a', 'b' ] in parallel +0ms
  fly run 'a' +0ms
  fly:log Starting a +0ms
  fly source [ 'src/a/*.txt' ] +0ms
  fly run 'b' +3ms
  fly:log Starting b +0ms
  fly source [ 'src/b/*.txt' ] +0ms
  fly:read read this file: src/a/a1.txt +6ms
  fly:read read this file: src/a/a2.txt +0ms
  fly:read read this file: src/a/a3.txt +0ms
  fly:read read this file: src/a/a4.txt +0ms
  fly:read read this file: src/b/b1.txt +1ms
  fly:read read this file: src/b/b2.txt +0ms
  fly:read read this file: src/b/b3.txt +0ms
  fly:read read this file: src/b/b4.txt +0ms
  fly:write write this file: dist/a/a1.txt +2ms
  fly:write write this file: dist/a/a2.txt +1ms
  fly:write write this file: dist/a/a3.txt +0ms
  fly:write write this file: dist/a/a4.txt +0ms
  fly:log Finished a in 13 ms +0ms
  fly:write write this file: dist/b/b1.txt +1ms
  fly:write write this file: dist/b/b2.txt +0ms
  fly:write write this file: dist/b/b3.txt +0ms
  fly:write write this file: dist/b/b4.txt +0ms
  fly:log Finished b in 11 ms +0ms
  fly:log Finished parallel in 18 ms +1ms

i.e. I haven’t seen any file to output is missing in the log.

Sorry for such long text ~(>_<~)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
lukeedcommented, Aug 19, 2016

@frantic1048 Solved πŸ˜ƒ Will ship with version 1.4, coming shortly

1reaction
lukeedcommented, Aug 19, 2016

Yeah 😠 annoying issue; thanks for your patience!

I’ll have some time to look at it tonight.

Read more comments on GitHub >

github_iconTop Results From Across the Web

async/await - not waiting before future() - Dart - Stack Overflow
The app doesn't stop executing, only the execution of the code after await is delayed until the returned Future completes.
Read more >
TSA PreCheck vs. Clear: What to Know - NerdWallet
TSA PreCheck speeds up the luggage screening portion of airport security and is more widely available than Clear.
Read more >
Python behind the scenes #12: how async/await works in Python
Mark functions as async. Call them with await. All of a sudden, your program becomes asynchronous – it can do useful things while...
Read more >
TSA Precheck, Global Entry or Clear: How to Choose ... - CNET
Unlike TSA PreCheck and Global Entry, Clear is run by a private company and not the government. It lets you jump right to...
Read more >
PreCheck, Global Entry or Clear? How to Get Through Airport ...
According to TSA PreCheck, in August 2019, 93 percent of the program's passengers waited less than five minutes. To be approved for PreCheck,Β ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found