@@ -140,7 +140,26 @@ jobs:
140140 certutil -d "sql:$HOME/.pki/nssdb" -A -t "CP,CP," -n TestAutomationSSL -i "./$BW_SSL_CERT"
141141
142142 - name : Install Bitwarden CLI
143- run : npm install -g @bitwarden/cli@2026.4.1
143+ run : npm install -g @bitwarden/cli@2026.6.0
144+
145+ # Temporary workaround for PM-39403: server >= 2026.6.1 returns responses
146+ # that node-fetch v2 treats as a premature close (ERR_STREAM_PREMATURE_CLOSE),
147+ # even though the response body is fully delivered. Neutralize the two
148+ # `new Error('Premature close')` emission sites in the CLI's bundled
149+ # node-fetch so seed:vault:ciphers can proceed. Remove this step once
150+ # PM-39403 ships and the lite image is rebuilt with the fix.
151+ - name : Patch @bitwarden/cli node-fetch (PM-39403 workaround)
152+ run : |
153+ NF=$(npm root -g)/@bitwarden/cli/node_modules/node-fetch/lib/index.js
154+ BEFORE=$(grep -c "Premature close" "$NF" || echo 0)
155+ # Each match is followed by `err.code = ...` and an emit/callback
156+ # line; delete the 3-line body, leaving the surrounding `if` empty.
157+ sed -i "/new Error('Premature close')/,+2d" "$NF"
158+ AFTER=$(grep -c "Premature close" "$NF" || echo 0)
159+ echo "node-fetch patch: removed $((BEFORE - AFTER)) of $BEFORE match(es)"
160+ if [ "$AFTER" != "0" ]; then
161+ echo "WARNING: not all Premature-close references removed; @bitwarden/cli's node-fetch may have changed shape"
162+ fi
144163
145164 - name : Install project dependencies
146165 run : |
@@ -155,6 +174,16 @@ jobs:
155174 - name : Build and start the test vault
156175 run : docker compose up -d --build --remove-orphans --wait --wait-timeout 60
157176
177+ - name : Wait for admin DB migrations to complete
178+ run : |
179+ echo "Waiting for admin DB migrations..."
180+ timeout 180 sh -c '
181+ until docker compose exec -T bitwarden sh -c "grep -q \"Migration successful\" /etc/bitwarden/logs/admin-*.log 2>/dev/null"; do
182+ sleep 2
183+ done
184+ '
185+ echo "Migrations complete."
186+
158187 - name : Generate crypto values
159188 run : npm run setup:crypto
160189
0 commit comments