Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Invoke
.finished.failure
in case of disabled retry
applied to ope…
…ration (#451) * Add test-case for bug with retry * Invoke `.finished.failure` in case of disabled `retry` applied to operation * Fix * Size
- Loading branch information
1 parent
0b3442b
commit 1b4ea89
Showing
4 changed files
with
91 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@farfetched/core': patch | ||
--- | ||
|
||
Invoke `.finished.failure` in case of disabled `retry` applied to operation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ | |
"size-limit": [ | ||
{ | ||
"path": "./dist/core.js", | ||
"limit": "15.95 kB" | ||
"limit": "16.1 kB" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { test, describe, vi, expect } from 'vitest'; | ||
import { allSettled, createWatch, fork } from 'effector'; | ||
|
||
import { unknownContract } from '../../contract/unknown_contract'; | ||
import { createJsonMutation } from '../../mutation/create_json_mutation'; | ||
import { httpError } from '../../errors/create_error'; | ||
import { retry } from '../retry'; | ||
|
||
describe('retry', () => { | ||
test('does not suppress finished.failure event after all retries in case of filter', async () => { | ||
const m = createJsonMutation({ | ||
request: { | ||
url: 'api.salo.com', | ||
method: 'POST', | ||
}, | ||
response: { | ||
contract: unknownContract, | ||
}, | ||
}); | ||
|
||
retry(m, { | ||
times: 3, | ||
delay: 100, | ||
/* Always return false, basically disabled retry */ | ||
filter: () => false, | ||
}); | ||
|
||
const onFailure = vi.fn(); | ||
|
||
const scope = fork({ | ||
handlers: [ | ||
[ | ||
m.__.executeFx, | ||
() => { | ||
throw httpError({ | ||
status: 400, | ||
statusText: 'Sorry', | ||
response: 'Sorry', | ||
}); | ||
}, | ||
], | ||
], | ||
}); | ||
|
||
createWatch({ unit: m.finished.failure, scope, fn: onFailure }); | ||
|
||
await allSettled(m.start, { scope }); | ||
|
||
expect(onFailure).toBeCalledTimes(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters