Skip to content

Latest commit

Β 

History

History
2183 lines (1534 loc) Β· 68.1 KB

File metadata and controls

2183 lines (1534 loc) Β· 68.1 KB
Β 
Feb 11, 2015
Feb 11, 2015
1
# Errors
2
Aug 28, 2017
Aug 28, 2017
3
<!--introduced_in=v4.0.0-->
Feb 11, 2015
Feb 11, 2015
4
<!--type=misc-->
5
Jan 4, 2016
Jan 4, 2016
6
Applications running in Node.js will generally experience four categories of
7
errors:
8
Jun 7, 2018
Jun 7, 2018
9
- Standard JavaScript errors such as {EvalError}, {SyntaxError}, {RangeError},
10
{ReferenceError}, {TypeError}, and {URIError}.
Jan 4, 2016
Jan 4, 2016
11
- System errors triggered by underlying operating system constraints such
Jun 7, 2018
Jun 7, 2018
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
Jan 4, 2016
Jan 4, 2016
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
Apr 18, 2016
Apr 18, 2016
20
instances of, the standard JavaScript {Error} class and are guaranteed
Jan 4, 2016
Jan 4, 2016
21
to provide *at least* the properties available on that class.
Feb 11, 2015
Feb 11, 2015
22
Nov 13, 2015
Nov 13, 2015
23
## Error Propagation and Interception
24
25
<!--type=misc-->
26
Jan 4, 2016
Jan 4, 2016
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
May 2, 2018
May 2, 2018
29
handled depends entirely on the type of `Error` and the style of the API that is
Jan 4, 2016
Jan 4, 2016
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
Jun 7, 2018
Jun 7, 2018
34
are handled using the [`try…catch` construct][try-catch] provided by the
Apr 20, 2017
Apr 20, 2017
35
JavaScript language.
Jan 4, 2016
Jan 4, 2016
36
Jan 21, 2016
Jan 21, 2016
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
```
Nov 13, 2015
Nov 13, 2015
46
Jan 4, 2016
Jan 4, 2016
47
Any use of the JavaScript `throw` mechanism will raise an exception that
Jun 7, 2018
Jun 7, 2018
48
*must* be handled using `try…catch` or the Node.js process will exit
Jan 4, 2016
Jan 4, 2016
49
immediately.
Nov 13, 2015
Nov 13, 2015
50
Jan 4, 2016
Jan 4, 2016
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.
Nov 13, 2015
Nov 13, 2015
54
Jan 4, 2016
Jan 4, 2016
55
Errors that occur within _Asynchronous APIs_ may be reported in multiple ways:
Nov 13, 2015
Nov 13, 2015
56
Jan 4, 2016
Jan 4, 2016
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.
Nov 13, 2015
Nov 13, 2015
61
Apr 25, 2017
Apr 25, 2017
62
<!-- eslint-disable no-useless-return -->
Jan 21, 2016
Jan 21, 2016
63
```js
Jan 4, 2016
Jan 4, 2016
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
```
Nov 7, 2017
Nov 7, 2017
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.
Jan 4, 2016
Jan 4, 2016
75
Jan 21, 2016
Jan 21, 2016
76
```js
Jan 4, 2016
Jan 4, 2016
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
});
Nov 13, 2015
Nov 13, 2015
87
Jan 4, 2016
Jan 4, 2016
88
connection.pipe(process.stdout);
89
```
Nov 13, 2015
Nov 13, 2015
90
Jan 4, 2016
Jan 4, 2016
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
Jun 7, 2018
Jun 7, 2018
93
`try…catch`. There is no comprehensive list of such methods; please
Jan 4, 2016
Jan 4, 2016
94
refer to the documentation of each method to determine the appropriate
95
error handling mechanism required.
Nov 13, 2015
Nov 13, 2015
96
Jan 4, 2016
Jan 4, 2016
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).
Nov 13, 2015
Nov 13, 2015
101
Nov 7, 2017
Nov 7, 2017
102
For *all* [`EventEmitter`][] objects, if an `'error'` event handler is not
Jan 4, 2016
Jan 4, 2016
103
provided, the error will be thrown, causing the Node.js process to report an
Apr 26, 2018
Apr 26, 2018
104
uncaught exception and crash unless either: The [`domain`][domains] module is
Apr 20, 2017
Apr 20, 2017
105
used appropriately or a handler has been registered for the
Apr 12, 2018
Apr 12, 2018
106
[`'uncaughtException'`][] event.
Nov 13, 2015
Nov 13, 2015
107
Jan 21, 2016
Jan 21, 2016
108
```js
109
const EventEmitter = require('events');
110
const ee = new EventEmitter();
Nov 13, 2015
Nov 13, 2015
111
Jan 21, 2016
Jan 21, 2016
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
```
Nov 13, 2015
Nov 13, 2015
118
Jun 7, 2018
Jun 7, 2018
119
Errors generated in this way *cannot* be intercepted using `try…catch` as
Jan 4, 2016
Jan 4, 2016
120
they are thrown *after* the calling code has already exited.
Nov 13, 2015
Nov 13, 2015
121
Jan 4, 2016
Jan 4, 2016
122
Developers must refer to the documentation for each method to determine
123
exactly how errors raised by those methods are propagated.
Nov 13, 2015
Nov 13, 2015
124
Dec 17, 2017
Dec 17, 2017
125
### Error-first callbacks
Nov 13, 2015
Nov 13, 2015
126
127
<!--type=misc-->
128
Jan 4, 2016
Jan 4, 2016
129
Most asynchronous methods exposed by the Node.js core API follow an idiomatic
Jul 7, 2018
Jul 7, 2018
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`.
Jan 4, 2016
Jan 4, 2016
135
Jan 21, 2016
Jan 21, 2016
136
```js
137
const fs = require('fs');
Jan 4, 2016
Jan 4, 2016
138
Dec 17, 2017
Dec 17, 2017
139
function errorFirstCallback(err, data) {
Mar 1, 2017
Mar 1, 2017
140
if (err) {
141
console.error('There was an error', err);
142
return;
143
}
144
console.log(data);
Jan 21, 2016
Jan 21, 2016
145
}
Nov 13, 2015
Nov 13, 2015
146
Dec 17, 2017
Dec 17, 2017
147
fs.readFile('/some/file/that/does-not-exist', errorFirstCallback);
148
fs.readFile('/some/file/that/does-exist', errorFirstCallback);
Jan 21, 2016
Jan 21, 2016
149
```
Jan 4, 2016
Jan 4, 2016
150
Jun 7, 2018
Jun 7, 2018
151
The JavaScript `try…catch` mechanism **cannot** be used to intercept errors
Apr 4, 2018
Apr 4, 2018
152
generated by asynchronous APIs. A common mistake for beginners is to try to
Dec 17, 2017
Dec 17, 2017
153
use `throw` inside an error-first callback:
Jan 4, 2016
Jan 4, 2016
154
Jan 21, 2016
Jan 21, 2016
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;
Jan 4, 2016
Jan 4, 2016
164
}
Jan 21, 2016
Jan 21, 2016
165
});
Mar 1, 2017
Mar 1, 2017
166
} catch (err) {
Jan 21, 2016
Jan 21, 2016
167
// This will not catch the throw!
Mar 1, 2017
Mar 1, 2017
168
console.error(err);
Jan 21, 2016
Jan 21, 2016
169
}
170
```
Feb 11, 2015
Feb 11, 2015
171
Jan 4, 2016
Jan 4, 2016
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
Mar 1, 2017
Mar 1, 2017
174
surrounding code (including the `try { } catch (err) { }` block will have
Jan 4, 2016
Jan 4, 2016
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.
Feb 11, 2015
Feb 11, 2015
179
Jan 4, 2016
Jan 4, 2016
180
## Class: Error
Feb 11, 2015
Feb 11, 2015
181
182
<!--type=class-->
183
Jan 4, 2016
Jan 4, 2016
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.
Feb 11, 2015
Feb 11, 2015
188
Sep 28, 2017
Sep 28, 2017
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
Jan 4, 2016
Jan 4, 2016
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.
Feb 11, 2015
Feb 11, 2015
195
Jan 4, 2016
Jan 4, 2016
196
### new Error(message)
Feb 11, 2015
Feb 11, 2015
197
Mar 2, 2017
Mar 2, 2017
198
* `message` {string}
Feb 8, 2017
Feb 8, 2017
199
Jan 4, 2016
Jan 4, 2016
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
Apr 4, 2018
Apr 4, 2018
205
(a) the beginning of *synchronous code execution*, or (b) the number of frames
Jan 4, 2016
Jan 4, 2016
206
given by the property `Error.stackTraceLimit`, whichever is smaller.
Feb 11, 2015
Feb 11, 2015
207
Jan 4, 2016
Jan 4, 2016
208
### Error.captureStackTrace(targetObject[, constructorOpt])
Nov 13, 2015
Nov 13, 2015
209
Feb 8, 2017
Feb 8, 2017
210
* `targetObject` {Object}
211
* `constructorOpt` {Function}
212
Nov 13, 2015
Nov 13, 2015
213
Creates a `.stack` property on `targetObject`, which when accessed returns
Jan 4, 2016
Jan 4, 2016
214
a string representing the location in the code at which
215
`Error.captureStackTrace()` was called.
Nov 13, 2015
Nov 13, 2015
216
Jan 21, 2016
Jan 21, 2016
217
```js
218
const myObject = {};
219
Error.captureStackTrace(myObject);
Mar 1, 2017
Mar 1, 2017
220
myObject.stack; // similar to `new Error().stack`
Jan 21, 2016
Jan 21, 2016
221
```
Nov 13, 2015
Nov 13, 2015
222
Feb 23, 2018
Feb 23, 2018
223
The first line of the trace will be prefixed with
224
`${myObject.name}: ${myObject.message}`.
Nov 13, 2015
Nov 13, 2015
225
Jan 4, 2016
Jan 4, 2016
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.
Nov 13, 2015
Nov 13, 2015
229
Jan 4, 2016
Jan 4, 2016
230
The `constructorOpt` argument is useful for hiding implementation
231
details of error generation from an end user. For instance:
Nov 13, 2015
Nov 13, 2015
232
Jan 21, 2016
Jan 21, 2016
233
```js
234
function MyError() {
235
Error.captureStackTrace(this, MyError);
236
}
Nov 13, 2015
Nov 13, 2015
237
Jan 21, 2016
Jan 21, 2016
238
// Without passing MyError to captureStackTrace, the MyError
May 20, 2016
May 20, 2016
239
// frame would show up in the .stack property. By passing
May 21, 2017
May 21, 2017
240
// the constructor, we omit that frame, and retain all frames below it.
Mar 1, 2017
Mar 1, 2017
241
new MyError().stack;
Jan 21, 2016
Jan 21, 2016
242
```
Nov 13, 2015
Nov 13, 2015
243
Jan 4, 2016
Jan 4, 2016
244
### Error.stackTraceLimit
Nov 13, 2015
Nov 13, 2015
245
Mar 8, 2017
Mar 8, 2017
246
* {number}
Feb 8, 2017
Feb 8, 2017
247
Jan 4, 2016
Jan 4, 2016
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)`).
Nov 13, 2015
Nov 13, 2015
251
Jan 4, 2016
Jan 4, 2016
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.
Nov 13, 2015
Nov 13, 2015
254
Jan 4, 2016
Jan 4, 2016
255
If set to a non-number value, or set to a negative number, stack traces will
256
not capture any frames.
Nov 13, 2015
Nov 13, 2015
257
Sep 9, 2017
Sep 9, 2017
258
### error.code
Apr 20, 2017
Apr 20, 2017
259
260
* {string}
261
262
The `error.code` property is a string label that identifies the kind of error.
Nov 7, 2018
Nov 7, 2018
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.
Apr 20, 2017
Apr 20, 2017
267
Sep 9, 2017
Sep 9, 2017
268
### error.message
Feb 11, 2015
Feb 11, 2015
269
Mar 8, 2017
Mar 8, 2017
270
* {string}
Feb 8, 2017
Feb 8, 2017
271
Apr 20, 2017
Apr 20, 2017
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).
Jan 4, 2016
Jan 4, 2016
278
Jan 21, 2016
Jan 21, 2016
279
```js
280
const err = new Error('The message');
Mar 1, 2017
Mar 1, 2017
281
console.error(err.message);
Nov 16, 2016
Nov 16, 2016
282
// Prints: The message
Jan 21, 2016
Jan 21, 2016
283
```
Feb 11, 2015
Feb 11, 2015
284
Mar 1, 2017
Mar 1, 2017
285
### error.stack
Feb 11, 2015
Feb 11, 2015
286
Mar 8, 2017
Mar 8, 2017
287
* {string}
Feb 8, 2017
Feb 8, 2017
288
289
The `error.stack` property is a string describing the point in the code at which
290
the `Error` was instantiated.
Jan 4, 2016
Jan 4, 2016
291
Jul 14, 2016
Jul 14, 2016
292
```txt
Jan 21, 2016
Jan 21, 2016
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
```
Feb 11, 2015
Feb 11, 2015
299
Jan 4, 2016
Jan 4, 2016
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
Jan 4, 2018
Jan 4, 2018
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:
Jan 4, 2016
Jan 4, 2016
314
Jan 21, 2016
Jan 21, 2016
315
```js
316
const cheetahify = require('./native-binding.node');
Jan 4, 2016
Jan 4, 2016
317
Jan 21, 2016
Jan 21, 2016
318
function makeFaster() {
319
// cheetahify *synchronously* calls speedy.
320
cheetahify(function speedy() {
321
throw new Error('oh no!');
322
});
323
}
324
Jun 29, 2017
Jun 29, 2017
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
Jan 21, 2016
Jan 21, 2016
341
```
Feb 11, 2015
Feb 11, 2015
342
Aug 23, 2015
Aug 23, 2015
343
The location information will be one of:
Feb 11, 2015
Feb 11, 2015
344
345
* `native`, if the frame represents a call internal to V8 (as in `[].forEach`).
Jan 4, 2016
Jan 4, 2016
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.
Feb 11, 2015
Feb 11, 2015
350
Jan 4, 2016
Jan 4, 2016
351
The string representing the stack trace is lazily generated when the
352
`error.stack` property is **accessed**.
Feb 11, 2015
Feb 11, 2015
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
Jan 4, 2016
Jan 4, 2016
358
System-level errors are generated as augmented `Error` instances, which are
Jan 11, 2016
Jan 11, 2016
359
detailed [here](#errors_system_errors).
Feb 11, 2015
Feb 11, 2015
360
Aug 10, 2017
Aug 10, 2017
361
## Class: AssertionError
362
Apr 4, 2018
Apr 4, 2018
363
A subclass of `Error` that indicates the failure of an assertion. For details,
364
see [`Class: assert.AssertionError`][].
Aug 10, 2017
Aug 10, 2017
365
Jan 4, 2016
Jan 4, 2016
366
## Class: RangeError
Feb 11, 2015
Feb 11, 2015
367
Dec 3, 2015
Dec 3, 2015
368
A subclass of `Error` that indicates that a provided argument was not within the
Jan 4, 2016
Jan 4, 2016
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
Jan 21, 2016
Jan 21, 2016
372
```js
373
require('net').connect(-1);
Jun 29, 2017
Jun 29, 2017
374
// throws "RangeError: "port" option should be >= 0 and < 65536: -1"
Jan 21, 2016
Jan 21, 2016
375
```
Feb 11, 2015
Feb 11, 2015
376
Jan 4, 2016
Jan 4, 2016
377
Node.js will generate and throw `RangeError` instances *immediately* as a form
Aug 23, 2015
Aug 23, 2015
378
of argument validation.
Feb 11, 2015
Feb 11, 2015
379
Jan 4, 2016
Jan 4, 2016
380
## Class: ReferenceError
Feb 11, 2015
Feb 11, 2015
381
Jan 4, 2016
Jan 4, 2016
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.
Feb 11, 2015
Feb 11, 2015
385
Jan 4, 2016
Jan 4, 2016
386
While client code may generate and propagate these errors, in practice, only V8
387
will do so.
Feb 11, 2015
Feb 11, 2015
388
Jan 21, 2016
Jan 21, 2016
389
```js
390
doesNotExist;
Jun 29, 2017
Jun 29, 2017
391
// throws ReferenceError, doesNotExist is not a variable in this program.
Jan 21, 2016
Jan 21, 2016
392
```
Feb 11, 2015
Feb 11, 2015
393
Jan 4, 2016
Jan 4, 2016
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.
Feb 11, 2015
Feb 11, 2015
397
Jan 4, 2016
Jan 4, 2016
398
## Class: SyntaxError
Feb 11, 2015
Feb 11, 2015
399
Dec 3, 2015
Dec 3, 2015
400
A subclass of `Error` that indicates that a program is not valid JavaScript.
Feb 11, 2015
Feb 11, 2015
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`,
Nov 16, 2015
Nov 16, 2015
403
`require`, or [vm][]. These errors are almost always indicative of a broken
Feb 11, 2015
Feb 11, 2015
404
program.
405
Jan 21, 2016
Jan 21, 2016
406
```js
407
try {
408
require('vm').runInThisContext('binary ! isNotOk');
Mar 1, 2017
Mar 1, 2017
409
} catch (err) {
Jan 21, 2016
Jan 21, 2016
410
// err will be a SyntaxError
411
}
412
```
Feb 11, 2015
Feb 11, 2015
413
Jan 4, 2016
Jan 4, 2016
414
`SyntaxError` instances are unrecoverable in the context that created them –
415
they may only be caught by other contexts.
Feb 11, 2015
Feb 11, 2015
416
Jan 4, 2016
Jan 4, 2016
417
## Class: TypeError
Nov 13, 2015
Nov 13, 2015
418
Jan 4, 2016
Jan 4, 2016
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
May 2, 2018
May 2, 2018
421
string would be considered a `TypeError`.
Nov 13, 2015
Nov 13, 2015
422
Jan 21, 2016
Jan 21, 2016
423
```js
Apr 18, 2016
Apr 18, 2016
424
require('url').parse(() => { });
Jun 29, 2017
Jun 29, 2017
425
// throws TypeError, since it expected a string
Jan 21, 2016
Jan 21, 2016
426
```
Nov 13, 2015
Nov 13, 2015
427
Jan 4, 2016
Jan 4, 2016
428
Node.js will generate and throw `TypeError` instances *immediately* as a form
Nov 13, 2015
Nov 13, 2015
429
of argument validation.
430
Jan 4, 2016
Jan 4, 2016
431
## Exceptions vs. Errors
Feb 11, 2015
Feb 11, 2015
432
433
<!--type=misc-->
434
Jan 4, 2016
Jan 4, 2016
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
May 2, 2018
May 2, 2018
439
instances of `Error`.
Feb 11, 2015
Feb 11, 2015
440
Jan 4, 2016
Jan 4, 2016
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.
Feb 11, 2015
Feb 11, 2015
444
445
## System Errors
446
Nov 7, 2018
Nov 7, 2018
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.
Jan 4, 2016
Jan 4, 2016
451
Nov 7, 2018
Nov 7, 2018
452
System errors are usually generated at the syscall level. For a comprehensive
453
list, see the [`errno`(3) man page][].
Feb 11, 2015
Feb 11, 2015
454
Nov 7, 2018
Nov 7, 2018
455
In Node.js, system errors are `Error` objects with extra properties.
Feb 11, 2015
Feb 11, 2015
456
Nov 2, 2017
Nov 2, 2017
457
### Class: SystemError
458
Nov 7, 2018
Nov 7, 2018
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
Nov 2, 2017
Nov 2, 2017
470
Nov 7, 2018
Nov 7, 2018
471
#### error.address
Nov 2, 2017
Nov 2, 2017
472
Nov 7, 2018
Nov 7, 2018
473
* {string}
Nov 2, 2017
Nov 2, 2017
474
Nov 7, 2018
Nov 7, 2018
475
If present, `error.address` is a string describing the address to which a
476
network connection failed.
Nov 2, 2017
Nov 2, 2017
477
Feb 11, 2015
Feb 11, 2015
478
#### error.code
479
Mar 8, 2017
Mar 8, 2017
480
* {string}
Feb 8, 2017
Feb 8, 2017
481
Nov 7, 2018
Nov 7, 2018
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.
Jan 4, 2016
Jan 4, 2016
490
Oct 16, 2016
Oct 16, 2016
491
#### error.errno
492
Mar 8, 2017
Mar 8, 2017
493
* {string|number}
Feb 8, 2017
Feb 8, 2017
494
Nov 7, 2018
Nov 7, 2018
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
Nov 7, 2018
Nov 7, 2018
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
Apr 20, 2017
Apr 20, 2017
499
of a string, it is the same as `error.code`.
Feb 11, 2015
Feb 11, 2015
500
Nov 7, 2018
Nov 7, 2018
501
#### error.info
Nov 13, 2015
Nov 13, 2015
502
Nov 7, 2018
Nov 7, 2018
503
* {Object}
Feb 8, 2017
Feb 8, 2017
504
Nov 7, 2018
Nov 7, 2018
505
If present, `error.info` is an object with details about the error condition.
Feb 8, 2017
Feb 8, 2017
506
Nov 7, 2018
Nov 7, 2018
507
#### error.message
Feb 8, 2017
Feb 8, 2017
508
Mar 8, 2017
Mar 8, 2017
509
* {string}
Feb 8, 2017
Feb 8, 2017
510
Nov 7, 2018
Nov 7, 2018
511
`error.message` is a system-provided human-readable description of the error.
Feb 8, 2017
Feb 8, 2017
512
Nov 7, 2018
Nov 7, 2018
513
#### error.path
Feb 8, 2017
Feb 8, 2017
514
Mar 8, 2017
Mar 8, 2017
515
* {string}
Feb 8, 2017
Feb 8, 2017
516
Nov 7, 2018
Nov 7, 2018
517
If present, `error.path` is a string containing a relevant invalid pathname.
Feb 8, 2017
Feb 8, 2017
518
519
#### error.port
520
Mar 8, 2017
Mar 8, 2017
521
* {number}
Feb 8, 2017
Feb 8, 2017
522
Nov 7, 2018
Nov 7, 2018
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.
Nov 13, 2015
Nov 13, 2015
530
Feb 11, 2015
Feb 11, 2015
531
### Common System Errors
532
Nov 7, 2018
Nov 7, 2018
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][].
Feb 11, 2015
Feb 11, 2015
535
Jan 4, 2016
Jan 4, 2016
536
- `EACCES` (Permission denied): An attempt was made to access a file in a way
537
forbidden by its file access permissions.
Feb 11, 2015
Feb 11, 2015
538
Apr 4, 2018
Apr 4, 2018
539
- `EADDRINUSE` (Address already in use): An attempt to bind a server
Jan 4, 2016
Jan 4, 2016
540
([`net`][], [`http`][], or [`https`][]) to a local address failed due to
541
another server on the local system already occupying that address.
Feb 11, 2015
Feb 11, 2015
542
Jan 4, 2016
Jan 4, 2016
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.
Feb 11, 2015
Feb 11, 2015
546
Jan 4, 2016
Jan 4, 2016
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.
Feb 11, 2015
Feb 11, 2015
551
Jan 4, 2016
Jan 4, 2016
552
- `EEXIST` (File exists): An existing file was the target of an operation that
553
required that the target not exist.
Feb 11, 2015
Feb 11, 2015
554
Jan 4, 2016
Jan 4, 2016
555
- `EISDIR` (Is a directory): An operation expected a file, but the given
556
pathname was a directory.
Feb 11, 2015
Feb 11, 2015
557
Jan 4, 2016
Jan 4, 2016
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
Apr 4, 2017
Apr 4, 2017
562
parallel, especially on systems (in particular, macOS) where there is a low
Jan 4, 2016
Jan 4, 2016
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.
Feb 11, 2015
Feb 11, 2015
565
Jan 4, 2016
Jan 4, 2016
566
- `ENOENT` (No such file or directory): Commonly raised by [`fs`][] operations
Apr 4, 2018
Apr 4, 2018
567
to indicate that a component of the specified pathname does not exist β€” no
Jan 4, 2016
Jan 4, 2016
568
entity (file or directory) could be found by the given path.
Feb 11, 2015
Feb 11, 2015
569
Jan 4, 2016
Jan 4, 2016
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`][].
Feb 11, 2015
Feb 11, 2015
572
Jan 4, 2016
Jan 4, 2016
573
- `ENOTEMPTY` (Directory not empty): A directory with entries was the target
Apr 4, 2018
Apr 4, 2018
574
of an operation that requires an empty directory β€” usually [`fs.unlink`][].
Feb 11, 2015
Feb 11, 2015
575
Jan 4, 2016
Jan 4, 2016
576
- `EPERM` (Operation not permitted): An attempt was made to perform an
577
operation that requires elevated privileges.
Feb 11, 2015
Feb 11, 2015
578
Jan 4, 2016
Jan 4, 2016
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.
Feb 11, 2015
Feb 11, 2015
583
Jan 4, 2016
Jan 4, 2016
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
Apr 4, 2018
Apr 4, 2018
586
encountered by [`http`][] or [`net`][] β€” often a sign that a `socket.end()`
Jan 4, 2016
Jan 4, 2016
587
was not properly called.
Apr 24, 2017
Apr 24, 2017
588
Apr 20, 2017
Apr 20, 2017
589
<a id="nodejs-error-codes"></a>
590
## Node.js Error Codes
591
Apr 13, 2018
Apr 13, 2018
592
<a id="ERR_AMBIGUOUS_ARGUMENT"></a>
593
### ERR_AMBIGUOUS_ARGUMENT
594
Aug 27, 2018
Aug 27, 2018
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.
Apr 13, 2018
Apr 13, 2018
601
Apr 25, 2017
Apr 25, 2017
602
<a id="ERR_ARG_NOT_ITERABLE"></a>
603
### ERR_ARG_NOT_ITERABLE
604
Nov 17, 2017
Nov 17, 2017
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.
Apr 25, 2017
Apr 25, 2017
607
Jun 28, 2017
Jun 28, 2017
608
<a id="ERR_ASSERTION"></a>
609
### ERR_ASSERTION
610
Nov 17, 2017
Nov 17, 2017
611
A special type of error that can be triggered whenever Node.js detects an
Jun 28, 2017
Jun 28, 2017
612
exceptional logic violation that should never occur. These are raised typically
613
by the `assert` module.
614
Sep 8, 2017
Sep 8, 2017
615
<a id="ERR_ASYNC_CALLBACK"></a>
616
### ERR_ASYNC_CALLBACK
617
Nov 17, 2017
Nov 17, 2017
618
An attempt was made to register something that is not a function as an
619
`AsyncHooks` callback.
Sep 8, 2017
Sep 8, 2017
620
621
<a id="ERR_ASYNC_TYPE"></a>
622
### ERR_ASYNC_TYPE
623
Nov 17, 2017
Nov 17, 2017
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.
Sep 8, 2017
Sep 8, 2017
626
Nov 4, 2018
Nov 4, 2018
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
Jul 12, 2017
Jul 12, 2017
640
<a id="ERR_BUFFER_OUT_OF_BOUNDS"></a>
641
### ERR_BUFFER_OUT_OF_BOUNDS
642
Nov 17, 2017
Nov 17, 2017
643
An operation outside the bounds of a `Buffer` was attempted.
Jul 12, 2017
Jul 12, 2017
644
Oct 2, 2017
Oct 2, 2017
645
<a id="ERR_BUFFER_TOO_LARGE"></a>
646
### ERR_BUFFER_TOO_LARGE
647
Nov 17, 2017
Nov 17, 2017
648
An attempt has been made to create a `Buffer` larger than the maximum allowed
649
size.
Oct 2, 2017
Oct 2, 2017
650
Jun 6, 2018
Jun 6, 2018
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
Nov 2, 2017
Nov 2, 2017
657
<a id="ERR_CANNOT_WATCH_SIGINT"></a>
658
### ERR_CANNOT_WATCH_SIGINT
659
Nov 17, 2017
Nov 17, 2017
660
Node.js was unable to watch for the `SIGINT` signal.
Nov 2, 2017
Nov 2, 2017
661
Jul 21, 2017
Jul 21, 2017
662
<a id="ERR_CHILD_CLOSED_BEFORE_REPLY"></a>
663
### ERR_CHILD_CLOSED_BEFORE_REPLY
664
Nov 17, 2017
Nov 17, 2017
665
A child process was closed before the parent received a reply.
Jul 21, 2017
Jul 21, 2017
666
Nov 29, 2017
Nov 29, 2017
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
Jun 7, 2018
Jun 7, 2018
676
STDERR/STDOUT, and the data's length is longer than the `maxBuffer` option.
Nov 29, 2017
Nov 29, 2017
677
Jun 6, 2018
Jun 6, 2018
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
May 27, 2017
May 27, 2017
684
<a id="ERR_CONSOLE_WRITABLE_STREAM"></a>
685
### ERR_CONSOLE_WRITABLE_STREAM
686
Nov 17, 2017
Nov 17, 2017
687
`Console` was instantiated without `stdout` stream, or `Console` has a
688
non-writable `stdout` or `stderr` stream.
May 27, 2017
May 27, 2017
689
Jun 6, 2018
Jun 6, 2018
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
Jun 28, 2017
Jun 28, 2017
695
<a id="ERR_CPU_USAGE"></a>
696
### ERR_CPU_USAGE
697
Nov 17, 2017
Nov 17, 2017
698
The native call from `process.cpuUsage` could not be processed.
Jun 28, 2017
Jun 28, 2017
699
Nov 11, 2017
Nov 11, 2017
700
<a id="ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED"></a>
701
### ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED
702
Nov 17, 2017
Nov 17, 2017
703
A client certificate engine was requested that is not supported by the version
704
of OpenSSL being used.
Nov 11, 2017
Nov 11, 2017
705
Sep 18, 2017
Sep 18, 2017
706
<a id="ERR_CRYPTO_ECDH_INVALID_FORMAT"></a>
707
### ERR_CRYPTO_ECDH_INVALID_FORMAT
708
Nov 17, 2017
Nov 17, 2017
709
An invalid value for the `format` argument was passed to the `crypto.ECDH()`
710
class `getPublicKey()` method.
Sep 18, 2017
Sep 18, 2017
711
Dec 1, 2017
Dec 1, 2017
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
Oct 25, 2017
Oct 25, 2017
719
<a id="ERR_CRYPTO_ENGINE_UNKNOWN"></a>
720
### ERR_CRYPTO_ENGINE_UNKNOWN
721
Nov 17, 2017
Nov 17, 2017
722
An invalid crypto engine identifier was passed to
Oct 25, 2017
Oct 25, 2017
723
[`require('crypto').setEngine()`][].
724
Oct 27, 2017
Oct 27, 2017
725
<a id="ERR_CRYPTO_FIPS_FORCED"></a>
726
### ERR_CRYPTO_FIPS_FORCED
727
Nov 17, 2017
Nov 17, 2017
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.
Oct 27, 2017
Oct 27, 2017
730
731
<a id="ERR_CRYPTO_FIPS_UNAVAILABLE"></a>
732
### ERR_CRYPTO_FIPS_UNAVAILABLE
733
Nov 17, 2017
Nov 17, 2017
734
An attempt was made to enable or disable FIPS mode, but FIPS mode was not
735
available.
Oct 27, 2017
Oct 27, 2017
736
Oct 26, 2017
Oct 26, 2017
737
<a id="ERR_CRYPTO_HASH_DIGEST_NO_UTF16"></a>
738
### ERR_CRYPTO_HASH_DIGEST_NO_UTF16
739
Nov 17, 2017
Nov 17, 2017
740
The UTF-16 encoding was used with [`hash.digest()`][]. While the
Oct 26, 2017
Oct 26, 2017
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
Nov 17, 2017
Nov 17, 2017
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.
Oct 26, 2017
Oct 26, 2017
750
751
<a id="ERR_CRYPTO_HASH_UPDATE_FAILED"></a>
752
### ERR_CRYPTO_HASH_UPDATE_FAILED
753
Nov 17, 2017
Nov 17, 2017
754
[`hash.update()`][] failed for any reason. This should rarely, if ever, happen.
Oct 26, 2017
Oct 26, 2017
755
Sep 20, 2018
Sep 20, 2018
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
Oct 23, 2017
Oct 23, 2017
761
<a id="ERR_CRYPTO_INVALID_DIGEST"></a>
762
### ERR_CRYPTO_INVALID_DIGEST
763
Nov 17, 2017
Nov 17, 2017
764
An invalid [crypto digest algorithm][] was specified.
Oct 23, 2017
Oct 23, 2017
765
Oct 30, 2017
Oct 30, 2017
766
<a id="ERR_CRYPTO_INVALID_STATE"></a>
767
### ERR_CRYPTO_INVALID_STATE
768
Nov 17, 2017
Nov 17, 2017
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()`.
Oct 30, 2017
Oct 30, 2017
771
Jun 13, 2018
Jun 13, 2018
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
Jun 13, 2018
Jun 13, 2018
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
Oct 26, 2017
Oct 26, 2017
790
<a id="ERR_CRYPTO_SIGN_KEY_REQUIRED"></a>
791
### ERR_CRYPTO_SIGN_KEY_REQUIRED
792
Nov 17, 2017
Nov 17, 2017
793
A signing `key` was not provided to the [`sign.sign()`][] method.
Oct 26, 2017
Oct 26, 2017
794
Oct 26, 2017
Oct 26, 2017
795
<a id="ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH"></a>
796
### ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH
797
Nov 17, 2017
Nov 17, 2017
798
[`crypto.timingSafeEqual()`][] was called with `Buffer`, `TypedArray`, or
799
`DataView` arguments of different lengths.
Oct 26, 2017
Oct 26, 2017
800
Jul 24, 2017
Jul 24, 2017
801
<a id="ERR_DNS_SET_SERVERS_FAILED"></a>
Aug 1, 2017
Aug 1, 2017
802
### ERR_DNS_SET_SERVERS_FAILED
Jul 24, 2017
Jul 24, 2017
803
Nov 17, 2017
Nov 17, 2017
804
`c-ares` failed to set the DNS server.
Jul 24, 2017
Jul 24, 2017
805
Nov 29, 2017
Nov 29, 2017
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
Sep 8, 2017
Sep 8, 2017
823
<a id="ERR_ENCODING_INVALID_ENCODED_DATA"></a>
824
### ERR_ENCODING_INVALID_ENCODED_DATA
825
Sep 17, 2018
Sep 17, 2018
826
Data provided to `TextDecoder()` API was invalid according to the encoding
Nov 17, 2017
Nov 17, 2017
827
provided.
Sep 8, 2017
Sep 8, 2017
828
829
<a id="ERR_ENCODING_NOT_SUPPORTED"></a>
830
### ERR_ENCODING_NOT_SUPPORTED
831
Sep 17, 2018
Sep 17, 2018
832
Encoding provided to `TextDecoder()` API was not one of the
Nov 17, 2017
Nov 17, 2017
833
[WHATWG Supported Encodings][].
Sep 8, 2017
Sep 8, 2017
834
Jun 13, 2017
Jun 13, 2017
835
<a id="ERR_FALSY_VALUE_REJECTION"></a>
836
### ERR_FALSY_VALUE_REJECTION
837
Nov 17, 2017
Nov 17, 2017
838
A `Promise` that was callbackified via `util.callbackify()` was rejected with a
839
falsy value.
Jun 13, 2017
Jun 13, 2017
840
Mar 21, 2018
Mar 21, 2018
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
Dec 22, 2017
Dec 22, 2017
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
Jun 28, 2017
Jun 28, 2017
853
<a id="ERR_HTTP_HEADERS_SENT"></a>
854
### ERR_HTTP_HEADERS_SENT
855
Nov 17, 2017
Nov 17, 2017
856
An attempt was made to add more headers after the headers had already been sent.
Jun 28, 2017
Jun 28, 2017
857
Nov 6, 2017
Nov 6, 2017
858
<a id="ERR_HTTP_INVALID_HEADER_VALUE"></a>
859
### ERR_HTTP_INVALID_HEADER_VALUE
860
Nov 17, 2017
Nov 17, 2017
861
An invalid HTTP header value was specified.
Nov 6, 2017
Nov 6, 2017
862
Jun 28, 2017
Jun 28, 2017
863
<a id="ERR_HTTP_INVALID_STATUS_CODE"></a>
864
### ERR_HTTP_INVALID_STATUS_CODE
865
Nov 17, 2017
Nov 17, 2017
866
Status code was outside the regular status code range (100-999).
Jun 28, 2017
Jun 28, 2017
867
868
<a id="ERR_HTTP_TRAILER_INVALID"></a>
869
### ERR_HTTP_TRAILER_INVALID
870
Nov 17, 2017
Nov 17, 2017
871
The `Trailer` header was set even though the transfer encoding does not support
872
that.
Jun 28, 2017
Jun 28, 2017
873
Jan 3, 2018
Jan 3, 2018
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
Aug 4, 2017
Aug 4, 2017
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
Sep 8, 2017
Sep 8, 2017
899
For HTTP/2 requests using the `CONNECT` method, the `:scheme` pseudo-header is
Aug 4, 2017
Aug 4, 2017
900
forbidden.
901
Jun 24, 2018
Jun 24, 2018
902
<a id="ERR_HTTP2_ERROR"></a>
903
### ERR_HTTP2_ERROR
904
905
A non-specific HTTP/2 error has occurred.
906
Dec 18, 2017
Dec 18, 2017
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
Sep 8, 2017
Sep 8, 2017
913
<a id="ERR_HTTP2_HEADERS_AFTER_RESPOND"></a>
914
### ERR_HTTP2_HEADERS_AFTER_RESPOND
915
Nov 17, 2017
Nov 17, 2017
916
An additional headers was specified after an HTTP/2 response was initiated.
Sep 8, 2017
Sep 8, 2017
917
Aug 4, 2017
Aug 4, 2017
918
<a id="ERR_HTTP2_HEADERS_SENT"></a>
919
### ERR_HTTP2_HEADERS_SENT
920
Nov 17, 2017
Nov 17, 2017
921
An attempt was made to send multiple response headers.
Aug 4, 2017
Aug 4, 2017
922
Jun 24, 2018
Jun 24, 2018
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
Aug 4, 2017
Aug 4, 2017
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
Nov 17, 2017
Nov 17, 2017
944
An invalid HTTP/2 header value was specified.
Aug 4, 2017
Aug 4, 2017
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
Sep 21, 2018
Sep 21, 2018
952
<a id="ERR_HTTP2_INVALID_ORIGIN"></a>
953
### ERR_HTTP2_INVALID_ORIGIN
954
955
HTTP/2 `ORIGIN` frames require a valid origin.
956
Aug 4, 2017
Aug 4, 2017
957
<a id="ERR_HTTP2_INVALID_PACKED_SETTINGS_LENGTH"></a>
Sep 13, 2017
Sep 13, 2017
958
### ERR_HTTP2_INVALID_PACKED_SETTINGS_LENGTH
Aug 4, 2017
Aug 4, 2017
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
Nov 17, 2017
Nov 17, 2017
973
An action was performed on an `Http2Session` object that had already been
974
destroyed.
Aug 4, 2017
Aug 4, 2017
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
Nov 17, 2017
Nov 17, 2017
984
An operation was performed on a stream that had already been destroyed.
Aug 4, 2017
Aug 4, 2017
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
Dec 30, 2017
Dec 30, 2017
990
required to send an acknowledgment that it has received and applied the new
Nov 17, 2017
Nov 17, 2017
991
`SETTINGS`. By default, a maximum number of unacknowledged `SETTINGS` frames may
Aug 4, 2017
Aug 4, 2017
992
be sent at any given time. This error code is used when that limit has been
993
reached.
994
Aug 13, 2018
Aug 13, 2018
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