question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using an async selector in another selector, throws an Uncaught promise

See original GitHub issue

Hi!

I have an async selector which relies on the return value from another async selector. The values are returned fine, but I get an error in the console saying Uncaught (in promise). I tried wrapping the selectors with a try..catch, but to no avail.

Example:

const selector1 = selector({
	key: "selector-1",
	get: async () => {
		const response = await.someAsyncAPICall();

		return response;
	},
});

const selector2 = selector({
	key: "selector-2",
	get: async ({ get }) => {
		const selector1Response = get(selector1);
		const response = await.someAsyncAPICallWithParams(selector1Response);

		return response;
	},
});


const selector3 = selector({
	key: "selector-3",
	get: async ({ get }) => {
		const selector2Response = get(selector2);
		const response = await.someAsyncAPICallWithParams(selector2Response);

		return response;
	},
});

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
kislakirubencommented, Nov 9, 2020

@justintoman well, I do need them if I’m doing some other API calls in those selectors as well. here’s an updated sandbox: https://codesandbox.io/s/twilight-sky-ru24z?file=/src/selectors.js

0reactions
drarmstrcommented, May 17, 2022

Resolved with 0.2.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

uncaught in promise nested async function promise error ...
I need to use fetch to post some data to server and then do other processes using javascript. but I'm confused on how...
Read more >
How to avoid uncaught async errors in Javascript
The reason behind this is that only the await throws an exception that the try..catch can handle, and the first await is for...
Read more >
Page - Playwright 中文文档
The method finds an element matching the specified selector within the page and passes it as a first argument to pageFunction . If...
Read more >
Simplifying your application state management with Recoil
Selector. “Selectors represent a function, or derived state in Recoil”, as it states in the official documentation.
Read more >
Using Cypress - Cypress Documentation
Is there a suggested way or best practice for how I should target elements or write element selectors? Can I prevent Cypress from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found