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

Regression: @typescript/require-await causes "Cannot set property 'hasAwait' of null" #1243

Closed
lll000111 opened this issue Nov 20, 2019 · 3 comments
Labels
duplicate This issue or pull request already exists package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@lll000111
Copy link

lll000111 commented Nov 20, 2019

I set

        'require-await': 'off',
        '@typescript-eslint/require-await': 'error',

and alsoturning off the typescript-eslint rule gets rid of the error.

I'm getting this error only since today after "yarn upgrade" upgrade typescript-eslint (it worked with the previous published version, I run that package upgrade command daily).

So this seems to be a regression.

EDIT: The error occurs in a file belonging to eslint. However the rule is turned off for eslint, and when I turn off the typescript-eslint rule the error disappears. So while it is reported in an eslint file it seems to originate from typescript-eslint? eslint was not updated in a month and it all worked -- with daily package updates and package.json set to "*" for all these packages to always get whatever is latest -- until I ran today's update.

TypeError: Cannot set property 'hasAwait' of null
Occurred while linting /home/mha/Projects/core/src/websocket-promisifier.ts:493

TypeError: Cannot set property 'hasAwait' of null
Occurred while linting /home/mha/Projects/core/src/websocket-promisifier.ts:493
    at Object.AwaitExpression (/home/mha/Projects/core/node_modules/eslint/lib/rules/require-await.js:92:36)
    at ReturnStatement (/home/mha/Projects/core/node_modules/@typescript-eslint/eslint-plugin/dist/rules/require-await.js:68:27)
    at /home/mha/Projects/core/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/home/mha/Projects/core/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/home/mha/Projects/core/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/home/mha/Projects/core/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/home/mha/Projects/core/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/home/mha/Projects/core/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:634:23)
    at /home/mha/Projects/core/node_modules/eslint/lib/linter/linter.js:936:32

The code at websocket-promisifier.ts:493 is ("function" header is line 492)

function sendFn(type: number, ...args: ReadonlyArray<unknown>): Promise<unknown> {
    return new Promise((resolve, reject) => {
    ...

Another file that has that error has it in a function that has this return statement:

    return (): Promise<void> => {
        if (lastAccessibleObjectsSize < RESUME_THRESHOLD) {
            return Promise.resolve();  // ESLINT ERROR HERE
        }
        ....
    };

eslintrc (top):

module.exports = {
    root: true,
    // eslint recommended defaults can be found in [INSTALL_DIR]/eslint/conf/eslint.json
    extends: [
        'eslint:recommended',
        'plugin:@typescript-eslint/recommended',
        'plugin:@typescript-eslint/recommended-requiring-type-checking',
        'plugin:@typescript-eslint/eslint-recommended'
    ],
    parser: '@typescript-eslint/parser',
    parserOptions: {
        ecmaVersion: 2018,
        ecmaFeatures: {impliedStrict: true},
        project: './tsconfig.json'
    },
    env: {
        es6: true,
        mocha: true,
        node: true,
        browser: true
    },
    plugins: ['@typescript-eslint', 'jsdoc'],
    rules: {
...

Versions

package version
@typescript-eslint/eslint-plugin 2.8.0
@typescript-eslint/parser 2.8.0
TypeScript 3.7.2
ESLint 6.6.0
node 12.13.1
npm `6.12.1
@lll000111 lll000111 added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Nov 20, 2019
@lll000111 lll000111 changed the title Regressions: @typescript/require-await causes "Cannot set property 'hasAwait' of null" Regression: @typescript/require-await causes "Cannot set property 'hasAwait' of null" Nov 20, 2019
@a-tarasyuk
Copy link
Contributor

The problem related to base rule - comment. I think the fix will be published in the next ESLint release.

cc @bradzacher

@lll000111
Copy link
Author

lll000111 commented Nov 20, 2019

This is all inside functions though — I'm not using global await.

Furthermore, there is no await at all in those locations, those are no "async" functions but regular functions returning a "traditional" manually created Promise.

@bradzacher bradzacher added the duplicate This issue or pull request already exists label Nov 20, 2019
@bradzacher
Copy link
Member

Duplicate of #1226

The fix has been merged to master, and will be released monday.
If you need it sooner, please try the canary tag.

@bradzacher bradzacher removed the triage Waiting for maintainers to take a look label Nov 20, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

3 participants