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

ERROR TypeError: Cannot read property 'runOutsideAngular' of undefined #5

Open
jaymehtasa opened this issue May 27, 2019 · 2 comments

Comments

@jaymehtasa
Copy link

jaymehtasa commented May 27, 2019

app.module.ts

const config = {
  url: environment.socketUrl,
  options: {
    transportOptions: {
      polling: {
        extraHeaders: {
          authorization:
            `Bearer ${localStorage.getItem('token')}`,
        },
      },
    },
  },
};

// ...

imports: [
    SocketIoModule.forRoot(config)
]

socket.service.ts

@Injectable({
  providedIn: 'root',
})
export class SocketService {
  constructor(private socket: Socket) {}

  public emitSocket() {
    return this.socket;
  }
}

error

AppComponent.html:118 ERROR TypeError: Cannot read property 'runOutsideAngular' of undefined
    at new WrappedSocket (socket-io.service.js:29)
    at SocketFactory (socket-io.module.js:14)
    at _callFactory (core.js:21282)
    at _createProviderInstance (core.js:21238)
    at resolveNgModuleDep (core.js:21199)
    at NgModuleRef_.push../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get (core.js:21907)
    at injectInjectorOnly (core.js:1774)
    at inject (core.js:1779)
    at injectArgs (core.js:1828)
    at core.js:15519

Angular

{
"@angular/compiler": "~7.2.0",
"@angular/core": "~7.2.0",
}
@jaymehtasa
Copy link
Author

jaymehtasa commented May 27, 2019

I found as soon as I inject Socket dependency injection in any service component, it throws this error.

@bloublou2014
Copy link

Setting es2015 on tsconfig solved the problem on my side:

 "compilerOptions": {
 // ....
"lib": [
      "es2018",
      "dom"
    ],
    "target": "es2015"
}

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