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

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

Closed
hassanasad opened this issue Dec 21, 2016 · 9 comments
Closed

Comments

@hassanasad
Copy link

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?

@clydin
Copy link
Member

clydin commented Dec 21, 2016

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

@hassanasad
Copy link
Author

hassanasad commented Dec 21, 2016

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

@peterpeterparker
Copy link

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

@hassanasad
Copy link
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).

@peterpeterparker
Copy link

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

@filipesilva
Copy link
Contributor

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

@roshenpo007
Copy link

@hassanasad Do you find any solution for this ?

@hassanasad
Copy link
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);
}

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants