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

chore: move start_server util in tests into a fixture #8461

Merged
merged 7 commits into from
Jan 13, 2023

Conversation

dominikg
Copy link
Member

so we don't have to try/finally inside the tests and leave playwright created contexrt alone

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Jan 11, 2023

⚠️ No Changeset found

Latest commit: 46e517f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Member

@benmccann benmccann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some tests are failing with:

Test timeout of 45000ms exceeded while tearing down "start_server".

Also, I see load does ignore ttl if fetch cache options says so flaking again, which I haven't seen flake at all since context.close() was introduced. It's possible that we've just had a lucky run, but I'd want to see that it's failing in other tests before merging this

How do we know that context.close() will be run before server.close() with this PR?

@Rich-Harris
Copy link
Member

How do we know that context.close() will be run before server.close() with this PR?

Hmm — we don't. This change basically reverts the context.close() changes. I think we could add context.close() inside the fixture though

@dominikg
Copy link
Member Author

according to https://playwright.dev/docs/test-fixtures , context is a fixture too, but one provided by playwright. the default page (another fixture) belongs to that context so i'd assume they are only closing the context after the page fixture

further down on that page they list the execution order https://playwright.dev/docs/test-fixtures#execution-order
additionally, fixtures can depend on each other (simply by using one fixture in another) so if teardown runs in reverse order and we need to ensure context is torn down before start_server, we'd have to make context depend on start_server? 🤔 arf

@benmccann benmccann changed the title [refactor] move start_server util in tests into a fixture chore: move start_server util in tests into a fixture Jan 11, 2023
/**
* @type {Set<import('net').Socket>}
*/
let sockets;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seemed to be working without all the socket craziness before. do we really need to add the extra complication?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is what i found as advice for force closing http.Server. I had logging locally and it actually does call socket.destroy in some cases, which should speed up the close at best and prevent timeouts at worst.

Given that this lives in a fixture and is out of the way for tests, not even used unless you actively call start_server(), i'd say it's worth it.

@Rich-Harris Rich-Harris merged commit 301aec9 into sveltejs:master Jan 13, 2023
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

Successfully merging this pull request may close these issues.

3 participants