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

Issue: Consecutive await automaFetch Calls Return Identical Results #1878

Open
qin9smile opened this issue Dec 29, 2024 · 0 comments
Open

Issue: Consecutive await automaFetch Calls Return Identical Results #1878

qin9smile opened this issue Dec 29, 2024 · 0 comments

Comments

@qin9smile
Copy link

Issue: Consecutive await automaFetch Calls Return Identical Results
Problem Description
When using await automaFetch in consecutive calls, the result of the second await is identical to the first, regardless of the second request's configuration or endpoint.

Reproduction Steps
Execute the following code:

javascript
Copy code
async function testAutomaFetch() {
try {
const firstResponse = await automaFetch('json', {
url: 'https://example.com/api/endpoint1',
method: 'GET',
});
console.log('First response:', firstResponse);

const secondResponse = await automaFetch('json', {
  url: 'https://example.com/api/endpoint2',
  method: 'GET',
});
console.log('Second response:', secondResponse);

} catch (error) {
console.error('Error:', error.message);
}
}

testAutomaFetch();
Observe the console logs.

Expected Behavior
firstResponse contains the response from https://example.com/api/endpoint1.
secondResponse contains the response from https://example.com/api/endpoint2.
Actual Behavior
firstResponse correctly contains the response from https://example.com/api/endpoint1.
secondResponse erroneously contains the same response as firstResponse, even though it was expected to fetch from https://example.com/api/endpoint2.
Impact
This issue severely limits the functionality of automaFetch when multiple asynchronous requests are required. It prevents workflows from correctly handling sequential API calls with different configurations.

Suggested Fix
Investigate the internal state management of automaFetch to ensure each call independently resolves with its respective request's result.
Ensure that the response of one automaFetch call does not overwrite or persist into subsequent calls.
Environment
Automa Version: [Your version here]
Browser: [Your browser/version here]
Script/Workflow Example:
javascript
Copy code
async function testAutomaFetch() {
try {
const firstResponse = await automaFetch('json', {
url: 'https://example.com/api/endpoint1',
method: 'GET',
});
console.log('First response:', firstResponse);

const secondResponse = await automaFetch('json', {
  url: 'https://example.com/api/endpoint2',
  method: 'GET',
});
console.log('Second response:', secondResponse);

} catch (error) {
console.error('Error:', error.message);
}
}

testAutomaFetch();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant