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

AbortController problem for update queries when bundled #43

Closed
smeckler opened this issue Nov 26, 2021 · 1 comment · Fixed by #44
Closed

AbortController problem for update queries when bundled #43

smeckler opened this issue Nov 26, 2021 · 1 comment · Fixed by #44
Labels
bug Something isn't working

Comments

@smeckler
Copy link
Contributor

Hi Ruben,

thank you for this library. It works well but I encountered a small problem with the AbortController when sending update queries. It's working when executed with Node, but the 'fetchUpdate' function has an error when it's bundled (with browserify or React).

  • JavaScript project
  • fetch-sparql-endpoint v2.3.2
  • abort-controller v3.0.0

Here is the problem in the browser:

const abort_controller_1 = require("abort-controller");

async fetchUpdate(endpoint, query) {
	const abortController = new abort_controller_1.AbortController(); // TypeError: abort_controller_1.AbortController is not a constructor
	const init = {
		method: 'POST',
		headers: {
			'content-type': 'application/sparql-update',
		},
		body: query,
		signal: abortController.signal,
	};
	await this.handleFetchCall(endpoint, init, { ignoreBody: true });
	abortController.abort();
}

A quick workaround was:

    let abortController;
    if (typeof window === 'undefined') { // --> nodeJS
        abortController = new abort_controller_1.AbortController();
    } else { // --> browser
        abortController = new AbortController();
    }
@rubensworks
Copy link
Owner

Hmm, this seems to be a bug in abort-controller: mysticatea/abort-controller#32

Looks like it can be fixed by moving towards the default export of AbortController instead of its named export.

A PR is definitely welcome! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants