-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(remix-express,remix-vercel): fix
request.signal
(#3626)
* fix: fix request.signal for express/vercel * fix express/vercel unit tests * add abort signals to arc/netlify requests * Update netlify/architect tests to assert new signal * add changeset
- Loading branch information
1 parent
c22b6ac
commit 81ec1b7
Showing
10 changed files
with
120 additions
and
35 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,8 @@ | ||
--- | ||
"@remix-run/architect": patch | ||
"@remix-run/express": patch | ||
"@remix-run/netlify": patch | ||
"@remix-run/vercel": patch | ||
--- | ||
|
||
fix: abort requests on response close instead of request close (#3626) |
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,61 @@ | ||
import { test, expect } from "@playwright/test"; | ||
|
||
import { PlaywrightFixture } from "./helpers/playwright-fixture"; | ||
import type { Fixture, AppFixture } from "./helpers/create-fixture"; | ||
import { createAppFixture, createFixture, js } from "./helpers/create-fixture"; | ||
|
||
let fixture: Fixture; | ||
let appFixture: AppFixture; | ||
|
||
test.beforeAll(async () => { | ||
fixture = await createFixture({ | ||
files: { | ||
"app/routes/index.jsx": js` | ||
import { json } from "@remix-run/node"; | ||
import { useActionData, useLoaderData, Form } from "@remix-run/react"; | ||
export async function action ({ request }) { | ||
console.log('action request.signal', request.signal) | ||
// New event loop causes express request to close | ||
await new Promise(r => setTimeout(r, 0)); | ||
return json({ aborted: request.signal.aborted }); | ||
} | ||
export function loader({ request }) { | ||
console.log('loader request.signal', request.signal) | ||
return json({ aborted: request.signal.aborted }); | ||
} | ||
export default function Index() { | ||
let actionData = useActionData(); | ||
let data = useLoaderData(); | ||
return ( | ||
<div> | ||
<p className="action">{actionData ? String(actionData.aborted) : "empty"}</p> | ||
<p className="loader">{String(data.aborted)}</p> | ||
<Form method="post"> | ||
<button type="submit">Submit</button> | ||
</Form> | ||
</div> | ||
) | ||
} | ||
`, | ||
}, | ||
}); | ||
|
||
// This creates an interactive app using puppeteer. | ||
appFixture = await createAppFixture(fixture); | ||
}); | ||
|
||
test.afterAll(async () => appFixture.close()); | ||
|
||
test("should not abort the request in a new event loop", async ({ page }) => { | ||
let app = new PlaywrightFixture(appFixture, page); | ||
await app.goto("/"); | ||
expect(await app.getHtml(".action")).toMatch("empty"); | ||
expect(await app.getHtml(".loader")).toMatch("false"); | ||
|
||
await app.clickElement('button[type="submit"]'); | ||
expect(await app.getHtml(".action")).toMatch("false"); | ||
expect(await app.getHtml(".loader")).toMatch("false"); | ||
}); |
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
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
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
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
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
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
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
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