Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const fs = require(`../fs`)

describe(`tracking fs`, () => {
it(`doesn't crash on accessing fs.constants`, () => {
expect(() => fs.constants).not.toThrow()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ function createProxyHandler(prefix, options) {
return value
}

const fieldDescriptor = Object.getOwnPropertyDescriptor(target, key)
if (fieldDescriptor && !fieldDescriptor.writable) {
// this is to prevent errors like:
// ```
// TypeError: 'get' on proxy: property 'constants' is a read - only and
// non - configurable data property on the proxy target but the proxy
// did not return its actual value
// (expected '[object Object]' but got '[object Object]')
// ```
return value
}

if (typeof value === `function`) {
return function wrapper(...args) {
const myErrorHolder = {
Expand Down