nodeca / pako

high speed zlib port to javascript, works in browser & node.js

Home Page:http://nodeca.github.io/pako/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: input.subarray is not a function

mangodan2003 opened this issue · comments

Hi,
pythons gzip is able to uncompress the message "Compressed Data" shown below. It was created by compressing the following string with flate2==1.0.0 in rust :

{"type":"subscription_successful","id":1,"media_stream":"video0"}

But pako version is 2.1.0 is failing as shown below:

- Compressed Data: [
-    31, 139,   8,   0,   0,   0,   0,   0,   0, 255,   1,  65,
-     0, 190, 255, 123,  34, 116, 121, 112, 101,  34,  58,  34,
-   115, 117,  98, 115,  99, 114, 105, 112, 116, 105, 111, 110,
-    95, 115, 117,  99,  99, 101, 115, 115, 102, 117, 108,  34,
-    44,  34, 105, 100,  34,  58,  49,  44,  34, 109, 101, 100,
-   105,  97,  95, 115, 116, 114, 101,  97, 109,  34,  58,  34,
-   118, 105, 100, 101, 111,  48,  34, 125,  55,  40, 118, 248,
-    65,   0,   0,   0
- ]
- /home/dan/tmp/pako-test/node_modules/pako/lib/zlib/inflate.js:874
-           output.set(input.subarray(next, next + copy), put);
-                            ^
- 
- TypeError: input.subarray is not a function
-     at Object.inflate (/home/dan/tmp/pako-test/node_modules/pako/lib/zlib/inflate.js:874:28)
-     at Inflate.push (/home/dan/tmp/pako-test/node_modules/pako/lib/inflate.js:224:27)
-     at Object.inflate (/home/dan/tmp/pako-test/node_modules/pako/lib/inflate.js:381:12)
-     at Object.<anonymous> (/home/dan/tmp/pako-test/test.js:9:31)
-     at Module._compile (node:internal/modules/cjs/loader:1254:14)
-     at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
-     at Module.load (node:internal/modules/cjs/loader:1117:32)
-     at Module._load (node:internal/modules/cjs/loader:958:12)
-     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
-     at node:internal/main/run_main_module:23:47
- 
- Node.js v18.16.0
- 

oh! so it works if I first convert the message to a Uint8Array. Odd thing is it was happy with many other messages in the same format before it failed with this specific one.