Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zlib.brotliCompressSync results in no response #38407

Closed
zyscoder opened this issue Apr 26, 2021 · 1 comment · Fixed by #38408
Closed

zlib.brotliCompressSync results in no response #38407

zyscoder opened this issue Apr 26, 2021 · 1 comment · Fixed by #38408
Assignees
Labels
brotli Issues and PRs related to the brotli dependency. confirmed-bug Issues with confirmed bugs. zlib Issues and PRs related to the zlib subsystem.

Comments

@zyscoder
Copy link

What steps will reproduce the bug?

Setup a node instance,

» node

and run the following javascript code.

zlib = require('zlib');zlib.brotliCompressSync('',{flush:3,finishFlush:4});

Then the node instance stuck and has no response even with "Ctl-D".

How often does it reproduce? Is there a required condition?

This can be always triggered following the steps above.

What is the expected behavior?

Don't cause any no response.

What do you see instead?

» node
Welcome to Node.js v16.0.0-pre.
Type ".help" for more information.
> zlib = require('zlib');zlib.brotliCompressSync('',{flush:3,finishFlush:4});


^C^C^C^C

                                                                                                                                                                                                 

Additional information

@Ayase-252 Ayase-252 added zlib Issues and PRs related to the zlib subsystem. confirmed-bug Issues with confirmed bugs. labels Apr 26, 2021
@XadillaX
Copy link
Member

It seems brotli does not has BrotliEncoderOperation with 4:

/** Operations that can be performed by streaming encoder. */
typedef enum BrotliEncoderOperation {
  /**
   * Process input.
   *
   * Encoder may postpone producing output, until it has processed enough input.
   */
  BROTLI_OPERATION_PROCESS = 0,
  /**
   * Produce output for all processed input.
   *
   * Actual flush is performed when input stream is depleted and there is enough
   * space in output stream. This means that client should repeat
   * ::BROTLI_OPERATION_FLUSH operation until @p available_in becomes @c 0, and
   * ::BrotliEncoderHasMoreOutput returns ::BROTLI_FALSE. If output is acquired
   * via ::BrotliEncoderTakeOutput, then operation should be repeated after
   * output buffer is drained.
   *
   * @warning Until flush is complete, client @b SHOULD @b NOT swap,
   *          reduce or extend input stream.
   *
   * When flush is complete, output data will be sufficient for decoder to
   * reproduce all the given input.
   */
  BROTLI_OPERATION_FLUSH = 1,
  /**
   * Finalize the stream.
   *
   * Actual finalization is performed when input stream is depleted and there is
   * enough space in output stream. This means that client should repeat
   * ::BROTLI_OPERATION_FINISH operation until @p available_in becomes @c 0, and
   * ::BrotliEncoderHasMoreOutput returns ::BROTLI_FALSE. If output is acquired
   * via ::BrotliEncoderTakeOutput, then operation should be repeated after
   * output buffer is drained.
   *
   * @warning Until finalization is complete, client @b SHOULD @b NOT swap,
   *          reduce or extend input stream.
   *
   * Helper function ::BrotliEncoderIsFinished checks if stream is finalized and
   * output fully dumped.
   *
   * Adding more input data to finalized stream is impossible.
   */
  BROTLI_OPERATION_FINISH = 2,
  /**
   * Emit metadata block to stream.
   *
   * Metadata is opaque to Brotli: neither encoder, nor decoder processes this
   * data or relies on it. It may be used to pass some extra information from
   * encoder client to decoder client without interfering with main data stream.
   *
   * @note Encoder may emit empty metadata blocks internally, to pad encoded
   *       stream to byte boundary.
   *
   * @warning Until emitting metadata is complete client @b SHOULD @b NOT swap,
   *          reduce or extend input stream.
   *
   * @warning The whole content of input buffer is considered to be the content
   *          of metadata block. Do @b NOT @e append metadata to input stream,
   *          before it is depleted with other operations.
   *
   * Stream is soft-flushed before metadata block is emitted. Metadata block
   * @b MUST be no longer than than 16MiB.
   */
  BROTLI_OPERATION_EMIT_METADATA = 3
} BrotliEncoderOperation;

XadillaX added a commit to XadillaX/node that referenced this issue Apr 26, 2021
@XadillaX XadillaX linked a pull request Apr 26, 2021 that will close this issue
@XadillaX XadillaX self-assigned this Apr 26, 2021
@XadillaX XadillaX added the brotli Issues and PRs related to the brotli dependency. label Apr 26, 2021
@Trott Trott closed this as completed in 9c7aa96 May 1, 2021
targos pushed a commit that referenced this issue May 3, 2021
Fixes: #38407

PR-URL: #38408
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
targos pushed a commit that referenced this issue May 30, 2021
Fixes: #38407

PR-URL: #38408
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
targos pushed a commit that referenced this issue Jun 5, 2021
Fixes: #38407

PR-URL: #38408
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
targos pushed a commit that referenced this issue Jun 5, 2021
Fixes: #38407

PR-URL: #38408
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
targos pushed a commit that referenced this issue Jun 11, 2021
Fixes: #38407

PR-URL: #38408
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
brotli Issues and PRs related to the brotli dependency. confirmed-bug Issues with confirmed bugs. zlib Issues and PRs related to the zlib subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants