ERR_BUFFER_CONTEXT_NOT_AVAILABLE


尝试从插件或嵌入器代码创建 Node.js Buffer 实例,而在与 Node.js 实例无关的 JS 引擎上下文中。 传给 Buffer 方法的数据将在方法返回时被释放。

当遇到此错误时,创建 Buffer 实例的一种可能的替代方法是创建普通的 Uint8Array,它仅在生成的对象的原型上有所不同。 Uint8Array 通常在 Buffer 所在的所有的 Node.js 核心 API 中被接受;它们在所有上下文中都可用。

An attempt was made to create a Node.js Buffer instance from addon or embedder code, while in a JS engine Context that is not associated with a Node.js instance. The data passed to the Buffer method will have been released by the time the method returns.

When encountering this error, a possible alternative to creating a Buffer instance is to create a normal Uint8Array, which only differs in the prototype of the resulting object. Uint8Arrays are generally accepted in all Node.js core APIs where Buffers are; they are available in all Contexts.