Skip to content

AjaxObservable: this / xhr is of type null #5414

@freiondrej

Description

@freiondrej

Bug Report

Current Behavior
In some circumstances the ajax observables throw an internal error when xhr is of type null (AjaxObservable.js:340) or this is of type null (AjaxObservable.js:278). (Possibly related to #4095 ?)

I'm using webpack so here is more description of which code parts are failing in case the line numbers are confused:

xhr being of type null:
this.status = xhr.status; from block function AjaxErrorImpl(message, xhr, request) {
this being of type null:
if (this.readyState === 4) { from block function xhrLoad(e) {

Reproduction

import { of, timer } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import {ajaxGet} from "rxjs/internal-compatibility";


const source = of('').pipe(switchMap(_ => ajaxGet('http://example.org')))

source.subscribe(x => console.log(x)); // ok

const source2 = timer(0).pipe(switchMap(_ => ajaxGet('http://example.org')))

source2.subscribe(x => console.log(x)); // also ok
const source3 = timer(1000).pipe(switchMap(_ => ajaxGet('http://example.org')))

source3.subscribe(x => console.log(x)); // not ok

Expected behavior
I expect the internal code not to fail this way - either produce a more friendly error if I'm doing something wrong or succeed without error.

Environment

  • Runtime: node 13.2.0, Firefox 76.0 / Safari 13.1
  • RxJS version: 6.5.4
  • webpack 4.42.0

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