codeant-ai-for-open-source[bot] commented on code in PR #39508:
URL: https://github.com/apache/superset/pull/39508#discussion_r3277901622
##########
superset-frontend/src/pages/FileHandler/index.test.tsx:
##########
@@ -165,9 +168,16 @@ beforeEach(() => {
.launchQueue;
});
-afterEach(() => {
+afterEach(async () => {
pendingTimerIds.forEach(id => clearTimeout(id));
pendingTimerIds.clear();
+ if (consumerPromise) {
+ await consumerPromise.catch(e => {
+ // eslint-disable-next-line no-console
+ console.warn('LaunchQueue consumer rejected:', e);
+ });
Review Comment:
**Suggestion:** The `catch` in `afterEach` logs rejections but suppresses
them, which lets tests pass even when background consumer work fails
unexpectedly. Re-throw after logging (or avoid catching here) so genuine async
failures still fail the test suite instead of being silently tolerated. [logic
error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ FileHandler tests may pass despite async consumer failures.
- ⚠️ Future file launch regressions may evade Jest detection.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. In `superset-frontend/src/pages/FileHandler/index.tsx`, observe that
`useEffect` at
lines 33–89 registers an async LaunchQueue consumer via
`launchQueue.setConsumer(async
(launchParams: FileLaunchParams) => { ... })`, so calling the consumer
returns a `Promise`
that can reject if any unhandled error occurs inside this async handler.
2. In `superset-frontend/src/pages/FileHandler/index.test.tsx`, see that
`setupLaunchQueue` at lines 125–143 wraps that consumer call in
`consumerPromise =
Promise.resolve(consumer({ files: [fileHandle] })).then(() => undefined);`
inside the
`setTimeout` at lines 133–137, meaning any rejection from the async consumer
surfaces as a
rejected `consumerPromise`.
3. Still in `index.test.tsx`, inspect the `afterEach` hook at lines 171–180:
after
clearing pending timers, it checks `if (consumerPromise)` and then executes
`await
consumerPromise.catch(e => { console.warn('LaunchQueue consumer rejected:',
e); });`,
logging the error but not rethrowing, and finally sets `consumerPromise =
null`.
4. Because Jest treats a fulfilled `afterEach` promise as a successful
teardown, any
rejected LaunchQueue consumer (e.g., due to a future regression in the async
file-handling
logic in `index.tsx`) will only produce a `console.warn` and will not cause
the
corresponding test to fail; there are no assertions on this warning in the
current tests,
so such background failures would be silently tolerated and could yield
false-positive
passing tests.
```
</details>
[Fix in
Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=c5cc7393d596410d8529d5faa1bd06bc&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
| [Fix in VSCode
Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=c5cc7393d596410d8529d5faa1bd06bc&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/src/pages/FileHandler/index.test.tsx
**Line:** 175:178
**Comment:**
*Logic Error: The `catch` in `afterEach` logs rejections but suppresses
them, which lets tests pass even when background consumer work fails
unexpectedly. Re-throw after logging (or avoid catching here) so genuine async
failures still fail the test suite instead of being silently tolerated.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39508&comment_hash=e96940458cc83fea5545ab92be848bb19dc13952143784eb76bcd288c7e67e0d&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39508&comment_hash=e96940458cc83fea5545ab92be848bb19dc13952143784eb76bcd288c7e67e0d&reaction=dislike'>👎</a>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]