Support multiple CSS file chunks and improve server timeout handling #15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for splitting large CSS files into multiple chunks to resolve timeout issues when serving large CSS files (>8MB). It also includes improvements to Docker build configuration and HTTP server timeout settings.
Problem
When serving large CSS files (e.g., 8MB+), the server would timeout after ~6 seconds due to:
Solution
1. Multiple CSS File Chunks Support
template.css?: Array<{ url: string, hash: string }>format{userUID}{hashPrefix8chars}Key changes:
File.initFile(): Supports multiple CSS chunks with hash-based deduplicationFile.createNote(): Processes CSS array format from templateFile.checkCss(): Returns array of CSS files instead of single objectFile.checkFiles(): Returns CSS files as array formatFile.checkFile(): Supports finding CSS chunks by hashWebNote.setCss(): Supports both array and string formatsnote.htmltemplate: Updated to allow multiple CSS link tags2. HTTP Server Timeout Configuration
keepAliveTimeout,requestTimeout, andheadersTimeoutSERVER_TIMEOUTenvironment variable3. Docker Build Improvements
node:lts-alpinelinux/amd64andlinux/arm64platforms only--build-from-sourceoption4. Bug Fixes
sha1()helper functionTechnical Details
CSS Chunk Storage
CSS chunks are stored with filenames following the pattern:
Example:
25debd7fa5ea0e4b82be9a39663d4a61(user UID) +abc12345(hash prefix) =25debd7fa5ea0e4b82be9a39663d4a61abc12345File Lookup Optimization
Multiple CSS files are queried using SQL LIKE pattern matching:
API Response Format
All CSS-related APIs now return array format:
Testing
Breaking Changes
None - fully backward compatible. The changes maintain backward compatibility with existing single CSS file format.
Files Changed
app/src/v1/File.ts- CSS handling logic for upload, check, and note creationapp/src/v1/WebNote.ts-setCss()method to support arraysapp/src/v1/templates/note.html- Removed hardcoded link tag, use placeholderapp/src/index.ts- HTTP server timeout configurationapp/src/v1/helpers.ts- Buffer to ArrayBuffer conversion fixDockerfile- Build dependencies and configuration.github/workflows/ci.yaml- Platform compatibility fixesRelated Issues
Fixes timeout issues when serving large CSS files (>8MB).