Skip to content

Instantly share code, notes, and snippets.

@nqbao
Last active November 18, 2015 15:17
Show Gist options
  • Save nqbao/6cb425ce3018ade9239f to your computer and use it in GitHub Desktop.
Save nqbao/6cb425ce3018ade9239f to your computer and use it in GitHub Desktop.
Babel 6 async error
{
"presets": ["es2015", "stage-0"]
}
export default class Abc {
async test() {
let client;
return await this.timeout()
}
timeout() {
return new Promise((resolve, reject) => {
setTimeout(resolve, 1000)
});
}
}
ReferenceError: client is not defined
at Abc._callee2$ (abc.js:3:15)
at tryCatch (/Users/baonguyen/Projects/sandbox/async-test/node_modules/babel-cli/node_modules/babel-polyfill/node_modules/regenerator/runtime.js:62:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/Users/baonguyen/Projects/sandbox/async-test/node_modules/babel-cli/node_modules/babel-polyfill/node_modules/regenerator/runtime.js:338:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Users/baonguyen/Projects/sandbox/async-test/node_modules/babel-cli/node_modules/babel-polyfill/node_modules/regenerator/runtime.js:95:21)
at step (/Users/baonguyen/Projects/sandbox/async-test/abc.js:9:273)
at /Users/baonguyen/Projects/sandbox/async-test/abc.js:9:443
at new Promise (/Users/baonguyen/Projects/sandbox/async-test/node_modules/babel-cli/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:197:7)
at /Users/baonguyen/Projects/sandbox/async-test/abc.js:9:99
at Abc.test (abc.js:5:32)
at _callee$ (main.js:7:15)
import Abc from './abc.js'
let abc = new Abc();
async function main() {
try {
await abc.test()
}
catch (ex) {
console.log(ex.stack)
}
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment