← Back to Discord Forum

API Testing - Error: apiRequestContext.get: Request context disposed.

Hello, I have a simple GET api test that most of the times passes, however there are times when the test fails with the following error

Test timeout of 30000ms exceeded.

Error: apiRequestContext.get: Request context disposed.

The test is simple, it looks like this

test('GET some resource', async ({ request }) => { const resp = await request.get(${URL}/api/something, { headers: { Cookie: cookie=${ADCookie}, }, }); expect(resp.status()).toBe(200); });

What is the cause of that error? potential solution/debugging? thank you!

This thread is trying to answer question "What is the cause of the error 'apiRequestContext.get: Request context disposed' in a GET API test and how can it be resolved?"

1 reply

I think that your get command is being disposed of by the timeout elapsing. What you could do is set a timeout on the get command less than the test timeout, this will allow you to control the timeout better. Alternatively you could increase the timeout of the test to allow a longer timeout. If this persists, you could look at toPass() were you have more control over retries. This could be related to a cold start if you are getting inconsistent timings, so my need to remedy it with a few retries.

Related Discord Threads

AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.