Skip to content

Argument of type 'Error' is not assignable to parameter of type 'Scheduler' #3672

Description

@hassanasad

Please provide us with the following information:

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
MacOS Seirra

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:

angular-cli: 1.0.0-beta.24
node: 7.2.1
os: darwin x64
@angular/common: 2.4.0
@angular/compiler: 2.4.0
@angular/core: 2.4.0
@angular/forms: 2.4.0
@angular/http: 2.4.0
@angular/platform-browser: 2.4.0
@angular/platform-browser-dynamic: 2.4.0
@angular/router: 3.4.0
@angular/compiler-cli: 2.4.0

After the update to angular-cli beta 24 i started getting this error:

ERROR in ./src/app/shared/services/baseapi.service.ts
Module build failed: Error: /Users/hassan/Code/project/src/app/shared/services/baseapi.service.ts (22,20): Argument of type 'Error' is not assignable to parameter of type 'Scheduler'.
  Property 'SchedulerAction' is missing in type 'Error'.)
/Users/hassan/Code/project/src/app/shared/services/baseapi.service.ts (43,20): Argument of type 'Error' is not assignable to parameter of type 'Scheduler'.)
    at _checkDiagnostics (/Users/hassan/Code/project/node_modules/@ngtools/webpack/src/loader.js:116:15)
    at /Users/hassan/Code/project/node_modules/@ngtools/webpack/src/loader.js:141:17
 @ ./src/app/shared/services/user.service.ts 18:0-51
 @ ./src/app/app.module.ts
 @ ./src/main.ts
 @ multi main

This is the code in context:

	httpGet( URL: string, requestOptions = this.getRequestOptions() ): Observable<any> {
		return this.http.get(URL, requestOptions)
			.retryWhen(error => error.delay(200))
			.timeout(20000, new Error('Request timeout'))   <===== LINE 22
			.map(this.extractData).catch(this.handleError);
	}

If i comment line 22 everything works fine. However, i do want to throw that error of timeout. Any suggestions please?

Activity

  1. clydin commented on Dec 21, 2016

    @clydin
    Member

    A timeout always throws a Rx.TimeoutError with the latest rxjs. So the error parameter is unnecessary.

  2. hassanasad commented on Dec 21, 2016

    @hassanasad
    Author

    @clydin thanks - what if i want to modify what it says ? :)

  3. peterpeterparker commented on Dec 25, 2016

    @peterpeterparker

    I'm interested too. I opened a same related question on stackoverflow

    http://stackoverflow.com/questions/41320125/how-to-implement-http-post-timeout-wth-last-rjxs-version

  4. hassanasad commented on Dec 27, 2016

    @hassanasad
    Author

    @peterpeterparker I can see that you updated your question/answer yesterday on stackoverflow. I am still not sure how can you throw a custom error message with that? (If I dont want to check error message in subscribe method).

  5. peterpeterparker commented on Dec 27, 2016

    @peterpeterparker

    @hassanasad I don't know neither except by checking the error in the error part, but at least, it works again ;)

  6. filipesilva commented on Dec 30, 2016

    @filipesilva
    Contributor

    Sorry but this isn't a CLI problem so I'll have to close it. Stack Overflow is a good place to ask.

  7. roshenpo007 commented on Nov 28, 2017

    @roshenpo007

    @hassanasad Do you find any solution for this ?

  8. hassanasad commented on Nov 28, 2017

    @hassanasad
    Author

    I changed my code as follows (it doesn't necessarily solve the issue but i got over it):

    // Get data from server
    httpGet( URL: string, requestOptions = this.getRequestOptions() ): Observable<any> {
    		
    	let tried = 0;
    	return this.http.get(URL, requestOptions)
    		.retryWhen(error => { 
    			// Retry when error.status is NOT 500
    			return error
    				.switchMap((error) => {
    					tried++;
    					// If number of tried are over - throw error in each case
    					if ( tried >= 4 ) return Observable.throw(error);
    
    					// Retry if error.status is NOT 500 otherwise try again
    					return (error.status === 500) ? Observable.throw(error) : Observable.of(error);
    				})
    				.delay( 500 )  // Number of miliseconds between each retry
    				.take( 4 );  // Number of tries
    		})
    		.timeout( 30000 )   // Total number of miliseconds to throw timeout error
    		.map(this.extractData)
    		.catch(this.handleError);
    }
    
  9. angular-automatic-lock-bot commented on Sep 7, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  10. locked and limited conversation to collaborators on Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions