Commit 4f6c656
app: fix /search hang when the route changes via $router.push
Symptom: clicking "Search" from the filters panel left the spinner
running forever, but refreshing the page made the same query
complete quickly.
Root cause: the polling loop that handles `fetch_query_result`
returning 202 (task pending) was only set up inside `mounted()`.
When the user submits the filter form, `updateSearchOptions` calls
`this.$router.push({name: 'search', query: this.searchParams})`,
which navigates within the same component. Vue Router reuses the
mounted component, so `mounted()` does NOT re-fire — only the watch
on `$route.query` does. The watch was calling `getSearchResults()`
directly, missing the polling-setup branch. The first
`fetch_query_result` poll returned 202, the response handler had no
branch for that case, and the spinner stuck. Refresh worked because
the component remounts on a hard page load.
Fix: pull the "fetch then poll if 202" logic out of `mounted` into
`runSearch()`. Both `mounted` and the watch call `runSearch`, so the
polling-setup runs in both cases. Also:
- `stopPolling()` helper that clears the interval AND nulls
`searchPollingInterval`. The previous code only called
`clearInterval(...)`; the handle was never reset, so subsequent
searches saw a stale truthy value and skipped polling setup.
- `runSearch` calls `stopPolling()` and resets `searchTaskId` at
the top, so a new query doesn't poll for the previous query's
stale task ID.
- Drop the dead `await … .then(…)` pattern in `mounted`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent c9534dd commit 4f6c656
1 file changed
Lines changed: 37 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
34 | 39 | | |
35 | 40 | | |
36 | 41 | | |
| |||
75 | 80 | | |
76 | 81 | | |
77 | 82 | | |
78 | | - | |
| 83 | + | |
79 | 84 | | |
80 | 85 | | |
81 | 86 | | |
82 | 87 | | |
83 | | - | |
| 88 | + | |
84 | 89 | | |
85 | 90 | | |
86 | 91 | | |
87 | 92 | | |
88 | | - | |
| 93 | + | |
89 | 94 | | |
90 | 95 | | |
91 | 96 | | |
| |||
110 | 115 | | |
111 | 116 | | |
112 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
113 | 145 | | |
114 | 146 | | |
115 | 147 | | |
| |||
161 | 193 | | |
162 | 194 | | |
163 | 195 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
| 196 | + | |
177 | 197 | | |
178 | 198 | | |
179 | 199 | | |
| |||
0 commit comments