-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
Expand file tree
/
Copy patherrors.md
More file actions
2183 lines (1534 loc) Β· 68.1 KB
/
errors.md
File metadata and controls
2183 lines (1534 loc) Β· 68.1 KB
Edit and raw actions
OlderNewer
Β
1
# Errors
2
3
<!--introduced_in=v4.0.0-->
4
<!--type=misc-->
5
6
Applications running in Node.js will generally experience four categories of
7
errors:
8
9
- Standard JavaScript errors such as {EvalError}, {SyntaxError}, {RangeError},
10
{ReferenceError}, {TypeError}, and {URIError}.
11
- System errors triggered by underlying operating system constraints such
12
as attempting to open a file that does not exist or attempting to send data
13
over a closed socket.
14
- User-specified errors triggered by application code.
15
- `AssertionError`s are a special class of error that can be triggered when
16
Node.js detects an exceptional logic violation that should never occur. These
17
are raised typically by the `assert` module.
18
19
All JavaScript and System errors raised by Node.js inherit from, or are
20
instances of, the standard JavaScript {Error} class and are guaranteed
21
to provide *at least* the properties available on that class.
22
23
## Error Propagation and Interception
24
25
<!--type=misc-->
26
27
Node.js supports several mechanisms for propagating and handling errors that
28
occur while an application is running. How these errors are reported and
29
handled depends entirely on the type of `Error` and the style of the API that is
30
called.
31
32
All JavaScript errors are handled as exceptions that *immediately* generate
33
and throw an error using the standard JavaScript `throw` mechanism. These
34
are handled using the [`tryβ¦catch` construct][try-catch] provided by the
35
JavaScript language.
36
37
```js
38
// Throws with a ReferenceError because z is undefined
39
try {
40
const m = 1;
41
const n = m + z;
42
} catch (err) {
43
// Handle the error here.
44
}
45
```
46
47
Any use of the JavaScript `throw` mechanism will raise an exception that
48
*must* be handled using `tryβ¦catch` or the Node.js process will exit
49
immediately.
50
51
With few exceptions, _Synchronous_ APIs (any blocking method that does not
52
accept a `callback` function, such as [`fs.readFileSync`][]), will use `throw`
53
to report errors.
54
55
Errors that occur within _Asynchronous APIs_ may be reported in multiple ways:
56
57
- Most asynchronous methods that accept a `callback` function will accept an
58
`Error` object passed as the first argument to that function. If that first
59
argument is not `null` and is an instance of `Error`, then an error occurred
60
that should be handled.
61
62
<!-- eslint-disable no-useless-return -->
63
```js
64
const fs = require('fs');
65
fs.readFile('a file that does not exist', (err, data) => {
66
if (err) {
67
console.error('There was an error reading the file!', err);
68
return;
69
}
70
// Otherwise handle the data
71
});
72
```
73
- When an asynchronous method is called on an object that is an
74
[`EventEmitter`][], errors can be routed to that object's `'error'` event.
75
76
```js
77
const net = require('net');
78
const connection = net.connect('localhost');
79
80
// Adding an 'error' event handler to a stream:
81
connection.on('error', (err) => {
82
// If the connection is reset by the server, or if it can't
83
// connect at all, or on any sort of error encountered by
84
// the connection, the error will be sent here.
85
console.error(err);
86
});
87
88
connection.pipe(process.stdout);
89
```
90
91
- A handful of typically asynchronous methods in the Node.js API may still
92
use the `throw` mechanism to raise exceptions that must be handled using
93
`tryβ¦catch`. There is no comprehensive list of such methods; please
94
refer to the documentation of each method to determine the appropriate
95
error handling mechanism required.
96
97
The use of the `'error'` event mechanism is most common for [stream-based][]
98
and [event emitter-based][] APIs, which themselves represent a series of
99
asynchronous operations over time (as opposed to a single operation that may
100
pass or fail).
101
102
For *all* [`EventEmitter`][] objects, if an `'error'` event handler is not
103
provided, the error will be thrown, causing the Node.js process to report an
104
uncaught exception and crash unless either: The [`domain`][domains] module is
105
used appropriately or a handler has been registered for the
106
[`'uncaughtException'`][] event.
107
108
```js
109
const EventEmitter = require('events');
110
const ee = new EventEmitter();
111
112
setImmediate(() => {
113
// This will crash the process because no 'error' event
114
// handler has been added.
115
ee.emit('error', new Error('This will crash'));
116
});
117
```
118
119
Errors generated in this way *cannot* be intercepted using `tryβ¦catch` as
120
they are thrown *after* the calling code has already exited.
121
122
Developers must refer to the documentation for each method to determine
123
exactly how errors raised by those methods are propagated.
124
125
### Error-first callbacks
126
127
<!--type=misc-->
128
129
Most asynchronous methods exposed by the Node.js core API follow an idiomatic
130
pattern referred to as an _error-first callback_. With this pattern, a callback
131
function is passed to the method as an argument. When the operation either
132
completes or an error is raised, the callback function is called with the
133
`Error` object (if any) passed as the first argument. If no error was raised,
134
the first argument will be passed as `null`.
135
136
```js
137
const fs = require('fs');
138
139
function errorFirstCallback(err, data) {
140
if (err) {
141
console.error('There was an error', err);
142
return;
143
}
144
console.log(data);
145
}
146
147
fs.readFile('/some/file/that/does-not-exist', errorFirstCallback);
148
fs.readFile('/some/file/that/does-exist', errorFirstCallback);
149
```
150
151
The JavaScript `tryβ¦catch` mechanism **cannot** be used to intercept errors
152
generated by asynchronous APIs. A common mistake for beginners is to try to
153
use `throw` inside an error-first callback:
154
155
```js
156
// THIS WILL NOT WORK:
157
const fs = require('fs');
158
159
try {
160
fs.readFile('/some/file/that/does-not-exist', (err, data) => {
161
// mistaken assumption: throwing here...
162
if (err) {
163
throw err;
164
}
165
});
166
} catch (err) {
167
// This will not catch the throw!
168
console.error(err);
169
}
170
```
171
172
This will not work because the callback function passed to `fs.readFile()` is
173
called asynchronously. By the time the callback has been called, the
174
surrounding code (including the `try { } catch (err) { }` block will have
175
already exited. Throwing an error inside the callback **can crash the Node.js
176
process** in most cases. If [domains][] are enabled, or a handler has been
177
registered with `process.on('uncaughtException')`, such errors can be
178
intercepted.
179
180
## Class: Error
181
182
<!--type=class-->
183
184
A generic JavaScript `Error` object that does not denote any specific
185
circumstance of why the error occurred. `Error` objects capture a "stack trace"
186
detailing the point in the code at which the `Error` was instantiated, and may
187
provide a text description of the error.
188
189
For crypto only, `Error` objects will include the OpenSSL error stack in a
190
separate property called `opensslErrorStack` if it is available when the error
191
is thrown.
192
193
All errors generated by Node.js, including all System and JavaScript errors,
194
will either be instances of, or inherit from, the `Error` class.
195
196
### new Error(message)
197
198
* `message` {string}
199
200
Creates a new `Error` object and sets the `error.message` property to the
201
provided text message. If an object is passed as `message`, the text message
202
is generated by calling `message.toString()`. The `error.stack` property will
203
represent the point in the code at which `new Error()` was called. Stack traces
204
are dependent on [V8's stack trace API][]. Stack traces extend only to either
205
(a) the beginning of *synchronous code execution*, or (b) the number of frames
206
given by the property `Error.stackTraceLimit`, whichever is smaller.
207
208
### Error.captureStackTrace(targetObject[, constructorOpt])
209
210
* `targetObject` {Object}
211
* `constructorOpt` {Function}
212
213
Creates a `.stack` property on `targetObject`, which when accessed returns
214
a string representing the location in the code at which
215
`Error.captureStackTrace()` was called.
216
217
```js
218
const myObject = {};
219
Error.captureStackTrace(myObject);
220
myObject.stack; // similar to `new Error().stack`
221
```
222
223
The first line of the trace will be prefixed with
224
`${myObject.name}: ${myObject.message}`.
225
226
The optional `constructorOpt` argument accepts a function. If given, all frames
227
above `constructorOpt`, including `constructorOpt`, will be omitted from the
228
generated stack trace.
229
230
The `constructorOpt` argument is useful for hiding implementation
231
details of error generation from an end user. For instance:
232
233
```js
234
function MyError() {
235
Error.captureStackTrace(this, MyError);
236
}
237
238
// Without passing MyError to captureStackTrace, the MyError
239
// frame would show up in the .stack property. By passing
240
// the constructor, we omit that frame, and retain all frames below it.
241
new MyError().stack;
242
```
243
244
### Error.stackTraceLimit
245
246
* {number}
247
248
The `Error.stackTraceLimit` property specifies the number of stack frames
249
collected by a stack trace (whether generated by `new Error().stack` or
250
`Error.captureStackTrace(obj)`).
251
252
The default value is `10` but may be set to any valid JavaScript number. Changes
253
will affect any stack trace captured *after* the value has been changed.
254
255
If set to a non-number value, or set to a negative number, stack traces will
256
not capture any frames.
257
258
### error.code
259
260
* {string}
261
262
The `error.code` property is a string label that identifies the kind of error.
263
`error.code` is the most stable way to identify an error. It will only change
264
between major versions of Node.js. In contrast, `error.message` strings may
265
change between any versions of Node.js. See [Node.js Error Codes][] for details
266
about specific codes.
267
268
### error.message
269
270
* {string}
271
272
The `error.message` property is the string description of the error as set by
273
calling `new Error(message)`. The `message` passed to the constructor will also
274
appear in the first line of the stack trace of the `Error`, however changing
275
this property after the `Error` object is created *may not* change the first
276
line of the stack trace (for example, when `error.stack` is read before this
277
property is changed).
278
279
```js
280
const err = new Error('The message');
281
console.error(err.message);
282
// Prints: The message
283
```
284
285
### error.stack
286
287
* {string}
288
289
The `error.stack` property is a string describing the point in the code at which
290
the `Error` was instantiated.
291
292
```txt
293
Error: Things keep happening!
294
at /home/gbusey/file.js:525:2
295
at Frobnicator.refrobulate (/home/gbusey/business-logic.js:424:21)
296
at Actor.<anonymous> (/home/gbusey/actors.js:400:8)
297
at increaseSynergy (/home/gbusey/actors.js:701:6)
298
```
299
300
The first line is formatted as `<error class name>: <error message>`, and
301
is followed by a series of stack frames (each line beginning with "at ").
302
Each frame describes a call site within the code that lead to the error being
303
generated. V8 attempts to display a name for each function (by variable name,
304
function name, or object method name), but occasionally it will not be able to
305
find a suitable name. If V8 cannot determine a name for the function, only
306
location information will be displayed for that frame. Otherwise, the
307
determined function name will be displayed with location information appended
308
in parentheses.
309
310
Frames are only generated for JavaScript functions. If, for example, execution
311
synchronously passes through a C++ addon function called `cheetahify` which
312
itself calls a JavaScript function, the frame representing the `cheetahify` call
313
will not be present in the stack traces:
314
315
```js
316
const cheetahify = require('./native-binding.node');
317
318
function makeFaster() {
319
// cheetahify *synchronously* calls speedy.
320
cheetahify(function speedy() {
321
throw new Error('oh no!');
322
});
323
}
324
325
makeFaster();
326
// will throw:
327
// /home/gbusey/file.js:6
328
// throw new Error('oh no!');
329
// ^
330
// Error: oh no!
331
// at speedy (/home/gbusey/file.js:6:11)
332
// at makeFaster (/home/gbusey/file.js:5:3)
333
// at Object.<anonymous> (/home/gbusey/file.js:10:1)
334
// at Module._compile (module.js:456:26)
335
// at Object.Module._extensions..js (module.js:474:10)
336
// at Module.load (module.js:356:32)
337
// at Function.Module._load (module.js:312:12)
338
// at Function.Module.runMain (module.js:497:10)
339
// at startup (node.js:119:16)
340
// at node.js:906:3
341
```
342
343
The location information will be one of:
344
345
* `native`, if the frame represents a call internal to V8 (as in `[].forEach`).
346
* `plain-filename.js:line:column`, if the frame represents a call internal
347
to Node.js.
348
* `/absolute/path/to/file.js:line:column`, if the frame represents a call in
349
a user program, or its dependencies.
350
351
The string representing the stack trace is lazily generated when the
352
`error.stack` property is **accessed**.
353
354
The number of frames captured by the stack trace is bounded by the smaller of
355
`Error.stackTraceLimit` or the number of available frames on the current event
356
loop tick.
357
358
System-level errors are generated as augmented `Error` instances, which are
359
detailed [here](#errors_system_errors).
360
361
## Class: AssertionError
362
363
A subclass of `Error` that indicates the failure of an assertion. For details,
364
see [`Class: assert.AssertionError`][].
365
366
## Class: RangeError
367
368
A subclass of `Error` that indicates that a provided argument was not within the
369
set or range of acceptable values for a function; whether that is a numeric
370
range, or outside the set of options for a given function parameter.
371
372
```js
373
require('net').connect(-1);
374
// throws "RangeError: "port" option should be >= 0 and < 65536: -1"
375
```
376
377
Node.js will generate and throw `RangeError` instances *immediately* as a form
378
of argument validation.
379
380
## Class: ReferenceError
381
382
A subclass of `Error` that indicates that an attempt is being made to access a
383
variable that is not defined. Such errors commonly indicate typos in code, or
384
an otherwise broken program.
385
386
While client code may generate and propagate these errors, in practice, only V8
387
will do so.
388
389
```js
390
doesNotExist;
391
// throws ReferenceError, doesNotExist is not a variable in this program.
392
```
393
394
Unless an application is dynamically generating and running code,
395
`ReferenceError` instances should always be considered a bug in the code
396
or its dependencies.
397
398
## Class: SyntaxError
399
400
A subclass of `Error` that indicates that a program is not valid JavaScript.
401
These errors may only be generated and propagated as a result of code
402
evaluation. Code evaluation may happen as a result of `eval`, `Function`,
403
`require`, or [vm][]. These errors are almost always indicative of a broken
404
program.
405
406
```js
407
try {
408
require('vm').runInThisContext('binary ! isNotOk');
409
} catch (err) {
410
// err will be a SyntaxError
411
}
412
```
413
414
`SyntaxError` instances are unrecoverable in the context that created them β
415
they may only be caught by other contexts.
416
417
## Class: TypeError
418
419
A subclass of `Error` that indicates that a provided argument is not an
420
allowable type. For example, passing a function to a parameter which expects a
421
string would be considered a `TypeError`.
422
423
```js
424
require('url').parse(() => { });
425
// throws TypeError, since it expected a string
426
```
427
428
Node.js will generate and throw `TypeError` instances *immediately* as a form
429
of argument validation.
430
431
## Exceptions vs. Errors
432
433
<!--type=misc-->
434
435
A JavaScript exception is a value that is thrown as a result of an invalid
436
operation or as the target of a `throw` statement. While it is not required
437
that these values are instances of `Error` or classes which inherit from
438
`Error`, all exceptions thrown by Node.js or the JavaScript runtime *will* be
439
instances of `Error`.
440
441
Some exceptions are *unrecoverable* at the JavaScript layer. Such exceptions
442
will *always* cause the Node.js process to crash. Examples include `assert()`
443
checks or `abort()` calls in the C++ layer.
444
445
## System Errors
446
447
Node.js generates system errors when exceptions occur within its runtime
448
environment. These usually occur when an application violates an operating
449
system constraint. For example, a system error will occur if an application
450
attempts to read a file that does not exist.
451
452
System errors are usually generated at the syscall level. For a comprehensive
453
list, see the [`errno`(3) man page][].
454
455
In Node.js, system errors are `Error` objects with extra properties.
456
457
### Class: SystemError
458
459
* `address` {string} If present, the address to which a network connection
460
failed
461
* `code` {string} The string error code
462
* `dest` {string} If present, the file path destination when reporting a file
463
system error
464
* `errno` {number|string} The system-provided error number
465
* `info` {Object} If present, extra details about the error condition
466
* `message` {string} A system-provided human-readable description of the error
467
* `path` {string} If present, the file path when reporting a file system error
468
* `port` {number} If present, the network connection port that is not available
469
* `syscall` {string} The name of the system call that triggered the error
470
471
#### error.address
472
473
* {string}
474
475
If present, `error.address` is a string describing the address to which a
476
network connection failed.
477
478
#### error.code
479
480
* {string}
481
482
The `error.code` property is a string representing the error code.
483
484
#### error.dest
485
486
* {string}
487
488
If present, `error.dest` is the file path destination when reporting a file
489
system error.
490
491
#### error.errno
492
493
* {string|number}
494
495
The `error.errno` property is a number or a string. If it is a number, it is a
496
negative value which corresponds to the error code defined in
497
[`libuv Error handling`]. See the libuv `errno.h` header file
498
(`deps/uv/include/uv/errno.h` in the Node.js source tree) for details. In case
499
of a string, it is the same as `error.code`.
500
501
#### error.info
502
503
* {Object}
504
505
If present, `error.info` is an object with details about the error condition.
506
507
#### error.message
508
509
* {string}
510
511
`error.message` is a system-provided human-readable description of the error.
512
513
#### error.path
514
515
* {string}
516
517
If present, `error.path` is a string containing a relevant invalid pathname.
518
519
#### error.port
520
521
* {number}
522
523
If present, `error.port` is the network connection port that is not available.
524
525
#### error.syscall
526
527
* {string}
528
529
The `error.syscall` property is a string describing the [syscall][] that failed.
530
531
### Common System Errors
532
533
This is a list of system errors commonly-encountered when writing a Node.js
534
program. For a comprehensive list, see the [`errno`(3) man page][].
535
536
- `EACCES` (Permission denied): An attempt was made to access a file in a way
537
forbidden by its file access permissions.
538
539
- `EADDRINUSE` (Address already in use): An attempt to bind a server
540
([`net`][], [`http`][], or [`https`][]) to a local address failed due to
541
another server on the local system already occupying that address.
542
543
- `ECONNREFUSED` (Connection refused): No connection could be made because the
544
target machine actively refused it. This usually results from trying to
545
connect to a service that is inactive on the foreign host.
546
547
- `ECONNRESET` (Connection reset by peer): A connection was forcibly closed by
548
a peer. This normally results from a loss of the connection on the remote
549
socket due to a timeout or reboot. Commonly encountered via the [`http`][]
550
and [`net`][] modules.
551
552
- `EEXIST` (File exists): An existing file was the target of an operation that
553
required that the target not exist.
554
555
- `EISDIR` (Is a directory): An operation expected a file, but the given
556
pathname was a directory.
557
558
- `EMFILE` (Too many open files in system): Maximum number of
559
[file descriptors][] allowable on the system has been reached, and
560
requests for another descriptor cannot be fulfilled until at least one
561
has been closed. This is encountered when opening many files at once in
562
parallel, especially on systems (in particular, macOS) where there is a low
563
file descriptor limit for processes. To remedy a low limit, run
564
`ulimit -n 2048` in the same shell that will run the Node.js process.
565
566
- `ENOENT` (No such file or directory): Commonly raised by [`fs`][] operations
567
to indicate that a component of the specified pathname does not exist β no
568
entity (file or directory) could be found by the given path.
569
570
- `ENOTDIR` (Not a directory): A component of the given pathname existed, but
571
was not a directory as expected. Commonly raised by [`fs.readdir`][].
572
573
- `ENOTEMPTY` (Directory not empty): A directory with entries was the target
574
of an operation that requires an empty directory β usually [`fs.unlink`][].
575
576
- `EPERM` (Operation not permitted): An attempt was made to perform an
577
operation that requires elevated privileges.
578
579
- `EPIPE` (Broken pipe): A write on a pipe, socket, or FIFO for which there is
580
no process to read the data. Commonly encountered at the [`net`][] and
581
[`http`][] layers, indicative that the remote side of the stream being
582
written to has been closed.
583
584
- `ETIMEDOUT` (Operation timed out): A connect or send request failed because
585
the connected party did not properly respond after a period of time. Usually
586
encountered by [`http`][] or [`net`][] β often a sign that a `socket.end()`
587
was not properly called.
588
589
<a id="nodejs-error-codes"></a>
590
## Node.js Error Codes
591
592
<a id="ERR_AMBIGUOUS_ARGUMENT"></a>
593
### ERR_AMBIGUOUS_ARGUMENT
594
595
A function argument is being used in a way that suggests that the function
596
signature may be misunderstood. This is thrown by the `assert` module when the
597
`message` parameter in `assert.throws(block, message)` matches the error message
598
thrown by `block` because that usage suggests that the user believes `message`
599
is the expected message rather than the message the `AssertionError` will
600
display if `block` does not throw.
601
602
<a id="ERR_ARG_NOT_ITERABLE"></a>
603
### ERR_ARG_NOT_ITERABLE
604
605
An iterable argument (i.e. a value that works with `for...of` loops) was
606
required, but not provided to a Node.js API.
607
608
<a id="ERR_ASSERTION"></a>
609
### ERR_ASSERTION
610
611
A special type of error that can be triggered whenever Node.js detects an
612
exceptional logic violation that should never occur. These are raised typically
613
by the `assert` module.
614
615
<a id="ERR_ASYNC_CALLBACK"></a>
616
### ERR_ASYNC_CALLBACK
617
618
An attempt was made to register something that is not a function as an
619
`AsyncHooks` callback.
620
621
<a id="ERR_ASYNC_TYPE"></a>
622
### ERR_ASYNC_TYPE
623
624
The type of an asynchronous resource was invalid. Note that users are also able
625
to define their own types if using the public embedder API.
626
627
<a id="ERR_BUFFER_CONTEXT_NOT_AVAILABLE"></a>
628
### ERR_BUFFER_CONTEXT_NOT_AVAILABLE
629
630
An attempt was made to create a Node.js `Buffer` instance from addon or embedder
631
code, while in a JS engine Context that is not associated with a Node.js
632
instance. The data passed to the `Buffer` method will have been released
633
by the time the method returns.
634
635
When encountering this error, a possible alternative to creating a `Buffer`
636
instance is to create a normal `Uint8Array`, which only differs in the
637
prototype of the resulting object. `Uint8Array`s are generally accepted in all
638
Node.js core APIs where `Buffer`s are; they are available in all Contexts.
639
640
<a id="ERR_BUFFER_OUT_OF_BOUNDS"></a>
641
### ERR_BUFFER_OUT_OF_BOUNDS
642
643
An operation outside the bounds of a `Buffer` was attempted.
644
645
<a id="ERR_BUFFER_TOO_LARGE"></a>
646
### ERR_BUFFER_TOO_LARGE
647
648
An attempt has been made to create a `Buffer` larger than the maximum allowed
649
size.
650
651
<a id="ERR_CANNOT_TRANSFER_OBJECT"></a>
652
### ERR_CANNOT_TRANSFER_OBJECT
653
654
The value passed to `postMessage()` contained an object that is not supported
655
for transferring.
656
657
<a id="ERR_CANNOT_WATCH_SIGINT"></a>
658
### ERR_CANNOT_WATCH_SIGINT
659
660
Node.js was unable to watch for the `SIGINT` signal.
661
662
<a id="ERR_CHILD_CLOSED_BEFORE_REPLY"></a>
663
### ERR_CHILD_CLOSED_BEFORE_REPLY
664
665
A child process was closed before the parent received a reply.
666
667
<a id="ERR_CHILD_PROCESS_IPC_REQUIRED"></a>
668
### ERR_CHILD_PROCESS_IPC_REQUIRED
669
670
Used when a child process is being forked without specifying an IPC channel.
671
672
<a id="ERR_CHILD_PROCESS_STDIO_MAXBUFFER"></a>
673
### ERR_CHILD_PROCESS_STDIO_MAXBUFFER
674
675
Used when the main process is trying to read data from the child process's
676
STDERR/STDOUT, and the data's length is longer than the `maxBuffer` option.
677
678
<a id="ERR_CLOSED_MESSAGE_PORT"></a>
679
### ERR_CLOSED_MESSAGE_PORT
680
681
There was an attempt to use a `MessagePort` instance in a closed
682
state, usually after `.close()` has been called.
683
684
<a id="ERR_CONSOLE_WRITABLE_STREAM"></a>
685
### ERR_CONSOLE_WRITABLE_STREAM
686
687
`Console` was instantiated without `stdout` stream, or `Console` has a
688
non-writable `stdout` or `stderr` stream.
689
690
<a id="ERR_CONSTRUCT_CALL_REQUIRED"></a>
691
### ERR_CONSTRUCT_CALL_REQUIRED
692
693
A constructor for a class was called without `new`.
694
695
<a id="ERR_CPU_USAGE"></a>
696
### ERR_CPU_USAGE
697
698
The native call from `process.cpuUsage` could not be processed.
699
700
<a id="ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED"></a>
701
### ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED
702
703
A client certificate engine was requested that is not supported by the version
704
of OpenSSL being used.
705
706
<a id="ERR_CRYPTO_ECDH_INVALID_FORMAT"></a>
707
### ERR_CRYPTO_ECDH_INVALID_FORMAT
708
709
An invalid value for the `format` argument was passed to the `crypto.ECDH()`
710
class `getPublicKey()` method.
711
712
<a id="ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY"></a>
713
### ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY
714
715
An invalid value for the `key` argument has been passed to the
716
`crypto.ECDH()` class `computeSecret()` method. It means that the public
717
key lies outside of the elliptic curve.
718
719
<a id="ERR_CRYPTO_ENGINE_UNKNOWN"></a>
720
### ERR_CRYPTO_ENGINE_UNKNOWN
721
722
An invalid crypto engine identifier was passed to
723
[`require('crypto').setEngine()`][].
724
725
<a id="ERR_CRYPTO_FIPS_FORCED"></a>
726
### ERR_CRYPTO_FIPS_FORCED
727
728
The [`--force-fips`][] command-line argument was used but there was an attempt
729
to enable or disable FIPS mode in the `crypto` module.
730
731
<a id="ERR_CRYPTO_FIPS_UNAVAILABLE"></a>
732
### ERR_CRYPTO_FIPS_UNAVAILABLE
733
734
An attempt was made to enable or disable FIPS mode, but FIPS mode was not
735
available.
736
737
<a id="ERR_CRYPTO_HASH_DIGEST_NO_UTF16"></a>
738
### ERR_CRYPTO_HASH_DIGEST_NO_UTF16
739
740
The UTF-16 encoding was used with [`hash.digest()`][]. While the
741
`hash.digest()` method does allow an `encoding` argument to be passed in,
742
causing the method to return a string rather than a `Buffer`, the UTF-16
743
encoding (e.g. `ucs` or `utf16le`) is not supported.
744
745
<a id="ERR_CRYPTO_HASH_FINALIZED"></a>
746
### ERR_CRYPTO_HASH_FINALIZED
747
748
[`hash.digest()`][] was called multiple times. The `hash.digest()` method must
749
be called no more than one time per instance of a `Hash` object.
750
751
<a id="ERR_CRYPTO_HASH_UPDATE_FAILED"></a>
752
### ERR_CRYPTO_HASH_UPDATE_FAILED
753
754
[`hash.update()`][] failed for any reason. This should rarely, if ever, happen.
755
756
<a id="ERR_CRYPTO_INCOMPATIBLE_KEY_OPTIONS"></a>
757
### ERR_CRYPTO_INCOMPATIBLE_KEY_OPTIONS
758
759
The selected public or private key encoding is incompatible with other options.
760
761
<a id="ERR_CRYPTO_INVALID_DIGEST"></a>
762
### ERR_CRYPTO_INVALID_DIGEST
763
764
An invalid [crypto digest algorithm][] was specified.
765
766
<a id="ERR_CRYPTO_INVALID_STATE"></a>
767
### ERR_CRYPTO_INVALID_STATE
768
769
A crypto method was used on an object that was in an invalid state. For
770
instance, calling [`cipher.getAuthTag()`][] before calling `cipher.final()`.
771
772
<a id="ERR_CRYPTO_PBKDF2_ERROR"></a>
773
### ERR_CRYPTO_PBKDF2_ERROR
774
775
The PBKDF2 algorithm failed for unspecified reasons. OpenSSL does not provide
776
more details and therefore neither does Node.js.
777
778
<a id="ERR_CRYPTO_SCRYPT_INVALID_PARAMETER"></a>
779
### ERR_CRYPTO_SCRYPT_INVALID_PARAMETER
780
781
One or more [`crypto.scrypt()`][] or [`crypto.scryptSync()`][] parameters are
782
outside their legal range.
783
784
<a id="ERR_CRYPTO_SCRYPT_NOT_SUPPORTED"></a>
785
### ERR_CRYPTO_SCRYPT_NOT_SUPPORTED
786
787
Node.js was compiled without `scrypt` support. Not possible with the official
788
release binaries but can happen with custom builds, including distro builds.
789
790
<a id="ERR_CRYPTO_SIGN_KEY_REQUIRED"></a>
791
### ERR_CRYPTO_SIGN_KEY_REQUIRED
792
793
A signing `key` was not provided to the [`sign.sign()`][] method.
794
795
<a id="ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH"></a>
796
### ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH
797
798
[`crypto.timingSafeEqual()`][] was called with `Buffer`, `TypedArray`, or
799
`DataView` arguments of different lengths.
800
801
<a id="ERR_DNS_SET_SERVERS_FAILED"></a>
802
### ERR_DNS_SET_SERVERS_FAILED
803
804
`c-ares` failed to set the DNS server.
805
806
<a id="ERR_DOMAIN_CALLBACK_NOT_AVAILABLE"></a>
807
### ERR_DOMAIN_CALLBACK_NOT_AVAILABLE
808
809
The `domain` module was not usable since it could not establish the required
810
error handling hooks, because
811
[`process.setUncaughtExceptionCaptureCallback()`][] had been called at an
812
earlier point in time.
813
814
<a id="ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE"></a>
815
### ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE
816
817
[`process.setUncaughtExceptionCaptureCallback()`][] could not be called
818
because the `domain` module has been loaded at an earlier point in time.
819
820
The stack trace is extended to include the point in time at which the
821
`domain` module had been loaded.
822
823
<a id="ERR_ENCODING_INVALID_ENCODED_DATA"></a>
824
### ERR_ENCODING_INVALID_ENCODED_DATA
825
826
Data provided to `TextDecoder()` API was invalid according to the encoding
827
provided.
828
829
<a id="ERR_ENCODING_NOT_SUPPORTED"></a>
830
### ERR_ENCODING_NOT_SUPPORTED
831
832
Encoding provided to `TextDecoder()` API was not one of the
833
[WHATWG Supported Encodings][].
834
835
<a id="ERR_FALSY_VALUE_REJECTION"></a>
836
### ERR_FALSY_VALUE_REJECTION
837
838
A `Promise` that was callbackified via `util.callbackify()` was rejected with a
839
falsy value.
840
841
<a id="ERR_FS_FILE_TOO_LARGE"></a>
842
### ERR_FS_FILE_TOO_LARGE
843
844
An attempt has been made to read a file whose size is larger than the maximum
845
allowed size for a `Buffer`.
846
847
<a id="ERR_FS_INVALID_SYMLINK_TYPE"></a>
848
### ERR_FS_INVALID_SYMLINK_TYPE
849
850
An invalid symlink type was passed to the [`fs.symlink()`][] or
851
[`fs.symlinkSync()`][] methods.
852
853
<a id="ERR_HTTP_HEADERS_SENT"></a>
854
### ERR_HTTP_HEADERS_SENT
855
856
An attempt was made to add more headers after the headers had already been sent.
857
858
<a id="ERR_HTTP_INVALID_HEADER_VALUE"></a>
859
### ERR_HTTP_INVALID_HEADER_VALUE
860
861
An invalid HTTP header value was specified.
862
863
<a id="ERR_HTTP_INVALID_STATUS_CODE"></a>
864
### ERR_HTTP_INVALID_STATUS_CODE
865
866
Status code was outside the regular status code range (100-999).
867
868
<a id="ERR_HTTP_TRAILER_INVALID"></a>
869
### ERR_HTTP_TRAILER_INVALID
870
871
The `Trailer` header was set even though the transfer encoding does not support
872
that.
873
874
<a id="ERR_HTTP2_ALTSVC_INVALID_ORIGIN"></a>
875
### ERR_HTTP2_ALTSVC_INVALID_ORIGIN
876
877
HTTP/2 ALTSVC frames require a valid origin.
878
879
<a id="ERR_HTTP2_ALTSVC_LENGTH"></a>
880
### ERR_HTTP2_ALTSVC_LENGTH
881
882
HTTP/2 ALTSVC frames are limited to a maximum of 16,382 payload bytes.
883
884
<a id="ERR_HTTP2_CONNECT_AUTHORITY"></a>
885
### ERR_HTTP2_CONNECT_AUTHORITY
886
887
For HTTP/2 requests using the `CONNECT` method, the `:authority` pseudo-header
888
is required.
889
890
<a id="ERR_HTTP2_CONNECT_PATH"></a>
891
### ERR_HTTP2_CONNECT_PATH
892
893
For HTTP/2 requests using the `CONNECT` method, the `:path` pseudo-header is
894
forbidden.
895
896
<a id="ERR_HTTP2_CONNECT_SCHEME"></a>
897
### ERR_HTTP2_CONNECT_SCHEME
898
899
For HTTP/2 requests using the `CONNECT` method, the `:scheme` pseudo-header is
900
forbidden.
901
902
<a id="ERR_HTTP2_ERROR"></a>
903
### ERR_HTTP2_ERROR
904
905
A non-specific HTTP/2 error has occurred.
906
907
<a id="ERR_HTTP2_GOAWAY_SESSION"></a>
908
### ERR_HTTP2_GOAWAY_SESSION
909
910
New HTTP/2 Streams may not be opened after the `Http2Session` has received a
911
`GOAWAY` frame from the connected peer.
912
913
<a id="ERR_HTTP2_HEADERS_AFTER_RESPOND"></a>
914
### ERR_HTTP2_HEADERS_AFTER_RESPOND
915
916
An additional headers was specified after an HTTP/2 response was initiated.
917
918
<a id="ERR_HTTP2_HEADERS_SENT"></a>
919
### ERR_HTTP2_HEADERS_SENT
920
921
An attempt was made to send multiple response headers.
922
923
<a id="ERR_HTTP2_HEADER_SINGLE_VALUE"></a>
924
### ERR_HTTP2_HEADER_SINGLE_VALUE
925
926
Multiple values were provided for an HTTP/2 header field that was required to
927
have only a single value.
928
929
<a id="ERR_HTTP2_INFO_STATUS_NOT_ALLOWED"></a>
930
### ERR_HTTP2_INFO_STATUS_NOT_ALLOWED
931
932
Informational HTTP status codes (`1xx`) may not be set as the response status
933
code on HTTP/2 responses.
934
935
<a id="ERR_HTTP2_INVALID_CONNECTION_HEADERS"></a>
936
### ERR_HTTP2_INVALID_CONNECTION_HEADERS
937
938
HTTP/1 connection specific headers are forbidden to be used in HTTP/2
939
requests and responses.
940
941
<a id="ERR_HTTP2_INVALID_HEADER_VALUE"></a>
942
### ERR_HTTP2_INVALID_HEADER_VALUE
943
944
An invalid HTTP/2 header value was specified.
945
946
<a id="ERR_HTTP2_INVALID_INFO_STATUS"></a>
947
### ERR_HTTP2_INVALID_INFO_STATUS
948
949
An invalid HTTP informational status code has been specified. Informational
950
status codes must be an integer between `100` and `199` (inclusive).
951
952
<a id="ERR_HTTP2_INVALID_ORIGIN"></a>
953
### ERR_HTTP2_INVALID_ORIGIN
954
955
HTTP/2 `ORIGIN` frames require a valid origin.
956
957
<a id="ERR_HTTP2_INVALID_PACKED_SETTINGS_LENGTH"></a>
958
### ERR_HTTP2_INVALID_PACKED_SETTINGS_LENGTH
959
960
Input `Buffer` and `Uint8Array` instances passed to the
961
`http2.getUnpackedSettings()` API must have a length that is a multiple of
962
six.
963
964
<a id="ERR_HTTP2_INVALID_PSEUDOHEADER"></a>
965
### ERR_HTTP2_INVALID_PSEUDOHEADER
966
967
Only valid HTTP/2 pseudoheaders (`:status`, `:path`, `:authority`, `:scheme`,
968
and `:method`) may be used.
969
970
<a id="ERR_HTTP2_INVALID_SESSION"></a>
971
### ERR_HTTP2_INVALID_SESSION
972
973
An action was performed on an `Http2Session` object that had already been
974
destroyed.
975
976
<a id="ERR_HTTP2_INVALID_SETTING_VALUE"></a>
977
### ERR_HTTP2_INVALID_SETTING_VALUE
978
979
An invalid value has been specified for an HTTP/2 setting.
980
981
<a id="ERR_HTTP2_INVALID_STREAM"></a>
982
### ERR_HTTP2_INVALID_STREAM
983
984
An operation was performed on a stream that had already been destroyed.
985
986
<a id="ERR_HTTP2_MAX_PENDING_SETTINGS_ACK"></a>
987
### ERR_HTTP2_MAX_PENDING_SETTINGS_ACK
988
989
Whenever an HTTP/2 `SETTINGS` frame is sent to a connected peer, the peer is
990
required to send an acknowledgment that it has received and applied the new
991
`SETTINGS`. By default, a maximum number of unacknowledged `SETTINGS` frames may
992
be sent at any given time. This error code is used when that limit has been
993
reached.
994
995
<a id="ERR_HTTP2_NESTED_PUSH"></a>
996
### ERR_HTTP2_NESTED_PUSH
997
998
An attempt was made to initiate a new push stream from within a push stream.
999
Nested push streams are not permitted.
1000