mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-21 13:39:22 +01:00
fix: cannot read body twice (#19750)
* fix: cannot read body twice * only read it once no matter what * fix tests but yucky * nicer * does this mean backend checks won't incorrectly run * comment
This commit is contained in:
parent
f09c76e0dd
commit
f236e2513a
4
.github/workflows/ci-backend.yml
vendored
4
.github/workflows/ci-backend.yml
vendored
@ -61,8 +61,10 @@ jobs:
|
||||
# the dependencies more clear if we separated the backend/frontend
|
||||
# code completely
|
||||
# really we should ignore ee/frontend/** but dorny doesn't support that
|
||||
# - '!ee/frontend/**'
|
||||
# including the negated rule appears to work
|
||||
# but makes it always match because the checked file always isn't `ee/frontend/**` 🙈
|
||||
- 'ee/**/*'
|
||||
- '!ee/frontend/**'
|
||||
- 'posthog/**/*'
|
||||
- 'bin/*.py'
|
||||
- requirements.txt
|
||||
|
@ -1555,17 +1555,18 @@ const api = {
|
||||
.withQueryString(toParams({ source: 'blob', blob_key: blobKey, version: '2' }))
|
||||
.getResponse()
|
||||
|
||||
const contentBuffer = new Uint8Array(await response.arrayBuffer())
|
||||
try {
|
||||
const textLines = await response.text()
|
||||
const textDecoder = new TextDecoder()
|
||||
const textLines = textDecoder.decode(contentBuffer)
|
||||
|
||||
if (textLines) {
|
||||
return textLines.split('\n')
|
||||
}
|
||||
} catch (e) {
|
||||
// Must be gzipped
|
||||
// we assume it is gzipped, swallow the error, and carry on below
|
||||
}
|
||||
|
||||
const contentBuffer = new Uint8Array(await response.arrayBuffer())
|
||||
return strFromU8(decompressSync(contentBuffer)).trim().split('\n')
|
||||
},
|
||||
|
||||
|
@ -127,6 +127,7 @@ describe('sessionRecordingDataLogic', () => {
|
||||
})
|
||||
resumeKeaLoadersErrors()
|
||||
})
|
||||
|
||||
it('fetch metadata success and snapshots error', async () => {
|
||||
silenceKeaLoadersErrors()
|
||||
// Unmount and remount the logic to trigger fetching the data again after the mock change
|
||||
|
@ -1,6 +1,12 @@
|
||||
import 'whatwg-fetch'
|
||||
import 'jest-canvas-mock'
|
||||
|
||||
import { TextEncoder, TextDecoder } from 'util'
|
||||
// Jest/JSDom don't know about TextEncoder but the browsers we support do
|
||||
// https://github.com/jsdom/jsdom/issues/2524
|
||||
global.TextDecoder = TextDecoder
|
||||
global.TextEncoder = TextEncoder
|
||||
|
||||
window.scrollTo = jest.fn()
|
||||
window.matchMedia = jest.fn(
|
||||
() => ({ matches: false, addListener: jest.fn(), removeListener: jest.fn() } as MediaQueryList)
|
||||
|
Loading…
Reference in New Issue
Block a user