Skip to content
Open
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
123 changes: 23 additions & 100 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -1,127 +1,50 @@
name: "CI"
name: CI

on:
pull_request_target:
types: [opened, synchronize, reopened]
push:
branches:
- 'v3'
- 'feature/*'
- 'fix/*'
pull_request:
workflow_dispatch:

permissions:
actions: read
checks: write
contents: read
deployments: read
issues: read
packages: read
pull-requests: write
repository-projects: read
security-events: read
statuses: write

env:
SAUCE_USERNAME: ${{secrets.SAUCE_USERNAME}}
SAUCE_ACCESS_KEY: ${{secrets.SAUCE_ACCESS_KEY}}
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
DISPLAY: ':99.0'

jobs:
approve:
runs-on: ubuntu-latest
steps:
- name: Approve
run: echo For security reasons, all pull requests need to be approved first before running any automated CI.

prepare:
test:
runs-on: ubuntu-latest
needs: [approve]
environment: open-env
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 2
persist-credentials: false

- name: Is environment ok
run: |
echo $SAUCE_USERNAME
echo ${{ github.event.pull_request.base.sha }} ${{ github.sha }} ${{ github.event.pull_request.head.sha }}

- name: Get specific changed files
id: source-changed
uses: tj-actions/changed-files@v1.1.3
with:
base_sha: ${{ github.sha }}
sha: ${{ github.event.pull_request.head.sha }}
files: |
src
test
karma.conf.js
Gruntfile.js
rollup.config.js
uses: actions/checkout@v4

- name: Install node.js
if: steps.source-changed.outputs.any_changed == 'true'
uses: actions/setup-node@v1
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 14.x

- name: Install xvfb
if: steps.source-changed.outputs.any_changed == 'true'
run: |
sudo apt-get install xvfb
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
node-version: 22

- name: Install dependencies
if: steps.source-changed.outputs.any_changed == 'true'
run: |
npm install
npm install -g grunt-cli
node_modules/.bin/rollup -c
run: npm install

- name: Install saucectl
if: steps.source-changed.outputs.any_changed == 'true'
uses: saucelabs/saucectl-run-action@v1
with:
skip-run: true
testing-environment: ""
concurrency: 10
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium firefox webkit

- name: Grunt test
if: steps.source-changed.outputs.any_changed == 'true'
run: |
grunt --version
sed -i '/log.info(`Check out job at/a\\ console.log(`::set-output name=urls-${sessionId}::${getSauceEndpoint(browserData.region)}${sessionId}`);' node_modules/karma-sauce-launcher/dist/reporter/reporter.js || true
- name: Build production bundles
run: npm run build

- name: Run tests
if: steps.source-changed.outputs.any_changed == 'true'
run: grunt karma:saucelabs
id: test
- name: Build instrumented test bundle
run: |
FLOW_COVERAGE=1 npm run build:test

- name: Run code coverage
if: steps.source-changed.outputs.any_changed == 'true'
uses: paambaati/codeclimate-action@v2.7.5
with:
coverageCommand: grunt karma:coverage
debug: true
prefix: .
coverageLocations: |
${{github.workspace}}/coverage/lcov/result.lcov:lcov
id: coverage
- name: Run browser suite with coverage
run: node scripts/run-browser-tests.mjs --browser all --coverage

- name: debug
run: ls -lhR coverage || true
- name: Coverage report
run: node scripts/coverage-report.mjs

- uses: LouisBrunner/checks-action@v1.1.1
if: steps.source-changed.outputs.any_changed == 'true'
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Testsuite passed
conclusion: ${{ job.status }}
output: |
{"summary":"${{join(steps.test.outputs.*, ', ')}}"}
name: coverage
path: coverage/
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ sauce_connect.log
dist/flow*cov*
dist/flow*map*
dist/flow*gz

# Browser test bundle
dist/flow.test.js
69 changes: 58 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,64 @@
# 3.0.0
# 3.0.0-alpha.1

## Breaking Changes
This release replaces the recursive XHR/event-handler upload design with one
async upload session.

## Highlights

- One `UploadSession` per Flow instance. XHR listeners only resolve request
promises; they never schedule another chunk.
- Async-generator read queue plus a bounded worker pool. Reads stay in chunk
order; uploads run concurrently up to `simultaneousUploads`.
- `upload()` is completion-oriented and idempotent while a session is active.
`pause()`, `resume()`, `cancel()` and `removeFile()` settle deterministically.
- Explicit chunk state machine: `pending`, `reading`, `uploading`, `success`,
`error`, `cancelled`.
- One awaited `readFileFn` replaces the `readFileFn` / `asyncReadFileFn` split.
It receives an `AbortSignal`; pause/cancel during a read no longer uploads
the stale result (#368).
- Empty files send exactly one zero-byte request (#375).
- Optional per-chunk checksums (`chunkChecksum`), sent as `flowChunkHash` and
cached across retries; server verification is documented.
- Premature EOF on a non-empty file is a truncation error by default
(`allowShortStream` is the explicit opt-in).
- Duplicate identifiers within one `addFiles` batch are filtered.
- A retry after an uncached read failure reinitializes via `initFileFn` and
rebuilds chunks instead of reading a partially consumed stream.
- A completed read is cached even when pause/cancel/error races with it, so a
stateful reader/encryptor does not lose consumed stream bytes.
- Add `streaming: true` for unknown/estimated-size inputs: dynamic chunk
creation until EOF, a zero-byte `flowChunkIsLast` marker, bounded buffering,
and pause/resume/retry/read-error handling. This removes the need for a
fragile ciphertext-size estimate.
- Retries are loops with abortable delays, not recursive `send()` calls.
- Native `EventTarget` + `CustomEvent`; no global `EventTarget.prototype`
patching.
- Explicit `hooks` option (`filterFile`, `fileAdded`, `filesAdded`,
`filesSubmitted`); no name-based hook/event dispatch.
- Zero runtime dependencies. No Babel/core-js/regenerator in the distributed
build.
- Browser test suite expanded to 145 specs: adapted v3 tests, targeted
regressions, transport/error edge cases, streaming/dynamic-size tests,
seeded randomized stress/invariant checks, and real-network upload/retry
tests. Chromium coverage: 97.4% statements / 86.7% branches; CI runs
Chromium, Firefox and WebKit.

## Breaking changes

### Events
- Events are distincts from hooks.
- Recognized events and hooks are now lower-snake-case (case-sensitive).
- Hooks are "file-added", "files-added", "files-submitted". "filter-file" is a filtering hook.
- Events are passed a native CustomEvent. IE:
v2: `flow.on('fileRemoved', (file) => { ... });`
v3: `flow.on('file-removed', ({detail: [file]}) => { ... });`
- `flow.on/off/once` are removed. Use `addEventListener`,
`removeEventListener` and `{once: true}`.
- Event details are objects (`event.detail.file`, `event.detail.message`, ...)
instead of arrays.
- Hooks are configured through `hooks: { ... }` instead of `on('file-added')`.
- `asyncReadFileFn` is removed. `readFileFn` is always awaited.
- `FlowChunk.readFinished()` and `preprocessFinished()` are removed.
- `Flow.uploadNextChunk()` is removed.
- `addFile(s)` take `{event, initFileFn}` options instead of positional
arguments.
- `await flow.upload()` now waits for the session to settle.
- A permanently failed file keeps its chunks instead of clearing them.

### Other
- FlowFile does not run bootstrap() upon instanciation. This must be done manually (or rely on *addFile* functions).
See [MIGRATION.md](MIGRATION.md) for the full mapping and examples.

# 2.0.0

Expand Down
78 changes: 0 additions & 78 deletions Gruntfile.js

This file was deleted.

Loading
Loading