Skip to content

Undocumented fs.FSWatcher::start() trips assertion in FSEventWrap::Start #17430

Closed
@rdeforest

Description

@rdeforest
  • Version: v8.2.1
  • Platform: Darwin a0999b17f5bd.ant.amazon.com 16.7.0 Darwin Kernel Version 16.7.0: Wed Oct 4 00:17:00 PDT 2017; root:xnu-3789.71.6~1/RELEASE_X86_64 x86_64
  • Subsystem: fs

I randomly discovered the undocumented start() method on the FSWatcher prototype and started experimenting with it before finding out it's not documented. I created a repro script for you, shown in the "screenshot" following this paragraph.

2017-12-02 16:42:07
me@MyMac~/ws/lambda
$ node --version
v8.2.1

2017-12-02 16:42:10
me@MyMac~/ws/lambda
$ uname -a
Darwin laptop-hostname 16.7.0 Darwin Kernel Version 16.7.0: Wed Oct  4 00:17:00 PDT 2017; root:xnu-3789.71.6~1/RELEASE_X86_64 x86_64

2017-12-02 16:42:25
me@MyMac~/ws/lambda
$ cat test.coffee
fs       = require 'fs'
util     = require 'util'

watcher  = null
put      = (text) -> (util.promisify (fs.writeFile)) 'test.dat', text
listener = (event, file) -> console.log {event, file}

put 'hello world'
  .then ->
    watcher = fs.watch 'test.dat', listener
    put "how you doin', world"
  .then ->
    watcher.start()
  .then ->
    watcher.close()

2017-12-02 16:42:31
me@MyMac~/ws/lambda
$ coffee test.coffee
{ event: 'change', file: 'test.dat' }
{ event: 'change', file: 'test.dat' }
/usr/local/Cellar/node/8.2.1/bin/node[42998]: ../src/fs_event_wrap.cc:117:static void node::(anonymous namespace)::FSEventWrap::Start(const FunctionCallbackInfo<v8::Value> &): Assertion `(wrap->initialized_) == (false)' failed.
 1: node::Abort() [/usr/local/bin/node]
 2: node::MakeCallback(v8::Isolate*, v8::Local<v8::Object>, char const*, int, v8::Local<v8::Value>*, node::async_context) [/usr/local/bin/node]
 3: node::(anonymous namespace)::FSEventWrap::Start(v8::FunctionCallbackInfo<v8::Value> const&) [/usr/local/bin/node]
 4: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [/usr/local/bin/node]
 5: v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/usr/local/bin/node]
 6: v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/usr/local/bin/node]
 7: 0x36bf65b840bd
Abort trap: 6

2017-12-02 16:42:44
me@MyMac~/ws/lambda
$ 

I was able to repro the bug in NodeJS v8.9.1 on Linux ec2-instance-hostname 4.4.20-0.1.fm.237.49.326.metal1.x86_64 #1 SMP Wed Sep 21 11:35:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

with a slightly different traceback. I'll try it on Windows when I get home.

I guess the issue is that the method exists at all? I hope this report is helpful. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.macosIssues and PRs related to the macOS platform / OSX.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions