-
Notifications
You must be signed in to change notification settings - Fork 0
Fjerner håndtering av etag-caching som ikke fungerer #7941
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR removes the vulnerable vite-plugin-node-polyfills dependency and its requirement by replacing the node-cache dependency with a custom TypeScript-based etag cache implementation for axios HTTP requests.
- Replaced
node-cachewith a native JavaScript Map-based cache implementation inaxiosEtag.ts - Removed
vite-plugin-node-polyfillsfrom all package configurations - Enhanced type safety by removing the file from loosely type-checked files
Reviewed Changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/rest-api/src/axios/axiosEtag.ts | Implemented custom etag cache with TTL and size limits, replacing node-cache dependency |
| packages/rest-api/package.json | Removed node-cache dependency |
| packages/*/vite.config.js | Removed vite-plugin-node-polyfills from all Vite configurations |
| packages/*/package.json | Removed vite-plugin-node-polyfills from all package dependencies |
| package.json | Removed node-cache from root dependencies |
| loosely-type-checked-files.json | Removed axiosEtag.ts from loosely typed files list |
| static get(uuid: string): CacheValue | undefined { | ||
| return this.getInstance().cache.get(uuid); | ||
| private isExpired(entry: CacheValue) { | ||
| return !!this.ttlMs && Date.now() - entry.t > this.ttlMs; |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The double negation !!this.ttlMs is unnecessary. Since this.ttlMs is typed as number | null, you can directly check this.ttlMs !== null for better readability.
| return !!this.ttlMs && Date.now() - entry.t > this.ttlMs; | |
| return this.ttlMs !== null && Date.now() - entry.t > this.ttlMs; |
| if (this.maxEntries && this.cache.size > this.maxEntries) { | ||
| // Simple FIFO eviction; can be upgraded to true LRU if necessary | ||
| const firstKey = this.cache.keys().next().value; | ||
| if (firstKey) this.cache.delete(firstKey); |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The eviction logic only removes one entry when the cache exceeds maxEntries, but should remove entries until the cache size is within the limit. The condition should be >= instead of >, and it should loop until cache.size < maxEntries.
| if (this.maxEntries && this.cache.size > this.maxEntries) { | |
| // Simple FIFO eviction; can be upgraded to true LRU if necessary | |
| const firstKey = this.cache.keys().next().value; | |
| if (firstKey) this.cache.delete(firstKey); | |
| if (this.maxEntries) { | |
| // Simple FIFO eviction; can be upgraded to true LRU if necessary | |
| while (this.cache.size > this.maxEntries) { | |
| const firstKey = this.cache.keys().next().value; | |
| if (firstKey) this.cache.delete(firstKey); | |
| } |
Behov / Bakgrunn
vite-plugin-node-polyfills har sårbare dependencies og er ikke oppdatert. Det ser ut til at vi bruker dette biblioteket for å støtte node-cache. node-cache brukes i en hjemmelaget cache-håndtering av etags. Denne cachingen ser heller ikke ut til å fungere som tiltenkt og er brukt få steder. Ved overgang til genererte endepunkter vil dette håndteres automatisk.
Løsning
Fjerner hjemmelaget cachehåndtering og pakkene den var avhengig av.
Andre endringer
Skjermbilder (hvis relevant)