Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions .changesets/fix-vite-20k-seed-population.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
{
"branch": "fix/vite-20k-seed-population",
"bump": "patch",
"environments": [
"production"
],
"packages": [
"@websublime/vite-plugin-open-api-core",
"@websublime/vite-plugin-open-api-server"
],
"changes": [
"7112339a6d1364052507d94381ea1cc08a8b2537",
"005682693dbf2d60bc9fbfa55926d80282fcdd0a",
"f345067c1cfbbce92a17a61f210ae2aebabec801",
"f317b1e0bd9e0b92f0caf6cdf046c2140a3384f2",
"639c7f60d27cf785bb6f3095117beb468e18e977",
"a50939d0d62e74c2d3b7d574c55c73c2554db66a",
"931844244915688d7a6e08b07194cd36356dade1",
"f640c756200b35ecb4e445248aa53232dbfa6e0e",
"45dd3f52c2482b1fb568f03308b3f7a8b9e39e56",
"5e9846a8cab0496ba2c4bde4f11b174339e86cbd",
"a07388cabe203c4e27f83a695fcd2d1d7539cde3",
"787dac6fb47fc6f036b426dbbb25ef020b7bcfe0",
"c225d6e8b8f72940ce225f5b58d03c769262a334",
"091c686e51c4804f08c24c5f664b947679c6f0cc",
"040e0b984f3b77beeabf152b1e378e26d19337f7",
"b12d89cf3e1a06ffcefb57096924b9e6b2e5b6e0",
"29ba36ba13df5d2e17e1eb81ac79d4580f363912",
"093d17ff5801983d722de39e61e7aceefa4d7019",
"97fbbbb019e2ce2c90485b771c435895baf32e53",
"8627a3ce86ea82a19d262bf0d652ff4f7b323ca8",
"cc048f0e7a87ec53f3e111f9f8c1cec56442c2ed",
"66c478f8092986fa498201587483fc8f61416e04",
"23bff103646176f2e616cd0869d36b09747cfbb4",
"7e17215aad7d66083d28e4208cc0ce391b02606d",
"94b75edfc3211765de2310fdce71ce4b6115b7ee",
"48eceee100d4dbe4b02fd337f8cc874f6ea4b71b",
"ad9c68de36d4c1893609aa068772b73655b1daaf",
"0fee4175f28427489fa728a474eefb2aeae21cc3",
"15a33dffaa291ee14b245a347f9c1ceb73c6e0f1",
"0cedc49ce1c778f7e5fde8f49c6c98a7de8fb58b",
"01da7c175e18c1386b66a0dbbd4d0320ba816ee6",
"22462b7f49c90a9b14973b4cdd21ae4e3f62009b",
"4d0f6aa43f6d6253aa5c6fa5a5125afe5cc8ff9e",
"5c47242e78fff9836bb29e43519e66131adb850e",
"9574aa95cc12cc67c5f9cacc155a1202ced1a849",
"518b43d954656f3a197608e18c3266d8fabaa3c4",
"680627ef2af228d96d35cf7838f7cddd568a1d5a",
"d6decf078d5dc393d60b66403a044ecf4af420ff",
"215db55b796bd6091d96f2d8f32deaf1af556d6a",
"10fa877bdf22b4c93d47d0837d5c1d42df9f8158",
"a9c295c4a4675d84dacadc6f551eb4e7c68aa700",
"18bc8ca00a1ad65329a2d67563545a2cd5ff0498",
"ab44398be43fce2958d2fa4cafa93e5ff9e368cd",
"c5bb469bcb5f4948a673245f913988af1947a6fd",
"e1ef500bc2752f84eff9cc5509d2d822c0eac2cf",
"791eab9254570db82f289dd0fc9caf2fa3f084e2",
"0e90ba397e1829434bcbbca745067aeb6bdf06a9",
"fcc263a2d327f7cdbf966e256b281cd6f24b6794",
"b8440e2c62192c61918522ec76eda6d9fe9e70f7",
"b9ecee1b9ffef1189e990ac550d453b1d868898c",
"ff3585e45a7cde8cce8e69ca8320ec467d703948",
"920aa364b763d38f0e323ed0d1fabf1777c781b1",
"bcdc4dbd10982df6a9d69badb8213d8902f0100c",
"0292cdc76820ea1544d7293d0935081a5529a86b",
"8cb0333889f6d747f28b12146a2d23a2f7a73ce9",
"a89a68e658c2062721a9fc612ee3ce7c0665deb8",
"151032eab051c407f2e84b82faaf71a0e5e0b9dc",
"1f054333c23135e66b785ce50008259c39615b91",
"9bd537dd8a166f28b7270ed63e7c4e923ec52b3c",
"b6a295595031941b3ec3324fb5bcbccfa52daf52",
"5bf5071294f924796190c374dc11051cc5c83004",
"ff82f49fdfa86d8f0b8604947cc84f54791638cd",
"ebdf0ff8d663b4058fd2b8e49c07239cf4e89924",
"06907a1353cbd356c7e557b014965d2d72a9d326",
"4227d7b03cbc1e2333d8edad4a1ac095897aacca",
"ee08e7795372772e0b0291049f4d7b128110f9d0",
"53ba344618dac42d6bafaffe7376d9f9a71523fa",
"fad30a6ce21cc7f0ca33de01ccd629e1b78fb2b7",
"b9bc6877589e8cc7bfe1de7c2ecce9b0298daaf5",
"7a7faa5397ea879470be32bbc3e6ab4c8ca100ab",
"8bac4ee2cb20752e03d2bf272c065e6627a7eb3b",
"aaaf52f62bc528969a79028fda9a6bd86c3070b8",
"22d6b50a70be0c58f1d24634933ac894434f51e2",
"1639cd27351289f3631b02cb9a70170d07255a99",
"6557578b51104b707d71b5cb2c138728edcee7c6",
"eed669cceafdd0a009d6c5b4fff52e12e80e9678",
"4b43b616d8b997c46c021074aca693135dba120a",
"c58f9a837ce0e9c5b0e31f3d0ab7ef61dadbe295",
"125d4467b11e0a582060d372c8157a8f3a584655",
"c0d28394a953a1a2a06c45c208549ffd84ef4ee9",
"b86ea75f2daef1b4275f2446ee4998b9f9f80547",
"532f03cc4ddf573612495f9332772274188a97ea",
"8fe89e21dd636c26ad81870cb8971c77d219b5b7",
"2f037ec4798018a1c1ff895cab3515850ad7c1c2",
"c831756f6e730541e5d3fa61cd58477428880dcc",
"9f4a6a3a52e9e9abe0ac3c6c33830a19d7524dbe",
"9288e85283c51732263f8dcca64f8acdb8f9d748",
"b5f0b1437718dd778876b9811268170912181b5d",
"f91ae5a1922d3f0252e289139b5342622246bd9b",
"f523c7caf298316f9635fb99a3a7aa23c6d7551f",
"e2880dba7e3acea4736a2d4136fc6baee81a5188",
"f6754a98833bbe36d3c86b28f7a942b79aab5d52",
"10a0c94368758ef7af9b1a53de154283b3d1e433",
"8ecc053864fac36e4feb59b4f71b4a66d038d9f1",
"eb6b05824e319eb78ccc491f8a4047dba1b313ef",
"f38dfa00bdc6f07e884a9dd5f2a27710535f77c8",
"467655ee544a9fc63eb716256427622b617af307",
"35e5eccdb05d578ed380432c03f4adfe3f27b8d7",
"4ddc0c638d19a806b78d6fde45edca5af1f356ea",
"f717863091bee302c5059e179ab2778f1431febb",
"f37cec1abcd62534f0a272258f2a0695565d4fcc",
"13343a22069816019df34b572562d53bdb5610ac",
"fbb4f222a05d641f556b42ba37e3f49f1e9613c9",
"bab5bf886c4058380058eb47ac3b6560773923b2",
"b6f231eef5e8d3ed6b77ef01f1c97b3cc6ccee60",
"e3a5927c964daa308cf67616c7bd317323b4344a",
"c7405dd8b54a772f610eeaec0b448f21d5e83c17",
"48cbda095a78af6d81035fc496d808493909a3c9",
"f2a89db2ea685da89c7d6b5602f6fb1840ada766",
"4b4bf3212f09bb69a3d249117df385712a96a353",
"e6b9993129cccb056c310dccd610cbf32f8b5f66",
"fb407897a645ceb716d0c62ada83e961c281a8af"
],
"created_at": "2026-03-03T14:44:38.222145Z",
"updated_at": "2026-03-03T14:45:03.731242Z"
}
36 changes: 26 additions & 10 deletions packages/core/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,14 @@ export async function createOpenApiServer(config: OpenApiServerConfig): Promise<
}
}

// Current handlers (mutable for hot reload).
// IMPORTANT: Route closures in buildRoutes capture this Map by reference.
// updateHandlers() mutates it in-place (clear + re-populate) so that existing
// route closures see the updated entries. Never reassign this variable — doing
// so would break the reference chain and silently stop handler dispatch.
// Current handlers and seeds (mutable for hot reload).
// IMPORTANT: Route closures in buildRoutes capture these Maps by reference.
// updateHandlers()/updateSeeds() mutate them in-place (clear + re-populate) so
// that existing route closures see the updated entries. Never reassign these
// variables — doing so would break the reference chain and silently stop
// handler/seed dispatch.
const currentHandlers = handlers;
let currentSeeds = seeds;
const currentSeeds = seeds;

// Build routes from OpenAPI document.
// IMPORTANT: buildRoutes must receive the exact same Map instances stored in
Expand Down Expand Up @@ -557,15 +558,30 @@ export async function createOpenApiServer(config: OpenApiServerConfig): Promise<
/**
* Update seed data at runtime (for hot reload)
*
* Repopulates the store with the new seed data and syncs the route
* builder's seed map so that the seed response priority path sees
* the updated entries.
*
* @remarks
* **Warning**: This method clears ALL data in the store before repopulating
* with the new seeds. Any manually added data (including data in schemas
* not present in the new seeds) will be permanently lost.
* **Mutation contract**: Route closures capture `currentSeeds` by
* reference at build time. This method mutates the Map in-place
* (`.clear()` + `.set()`) so closures see the updates. Never replace
* the Map — that breaks the reference chain.
*
* **Warning**: This method clears ALL data in the store before
* repopulating with the new seeds. Any manually added data (including
* data in schemas not present in the new seeds) will be permanently lost.
*
* @param newSeeds - New seeds map (schema name -> array of items)
*/
updateSeeds(newSeeds: Map<string, unknown[]>): void {
currentSeeds = newSeeds;
// Mutate the existing Map in-place so route closures see the updates.
// IMPORTANT: buildRoutes captures this Map by reference — never replace it.
// This mirrors the pattern used by updateHandlers().
currentSeeds.clear();
for (const [key, value] of newSeeds) {
currentSeeds.set(key, value);
}

// Re-populate store with new seeds
// Note: clearAll() removes ALL schemas, not just the ones being updated
Expand Down
Loading