Skip to content

fs.truncate after promisify do not resolve or reject Promise, if there is fs.open promisifyed function in same file #19923

@dimaMachina

Description

@dimaMachina
  • Version: v9.3.0
  • Platform: macOS 10.13.1 High Sierra

I'm facing a problem when I have many fs promisifyed functions in one file, specifically promisifyed fs.truncate and fs.open in one file

This work fine, result undefined as expected

const fs = require('fs');
const path = require('path');
const { promisify } = require('util');

fs.truncate = promisify(fs.truncate);

fs.truncate(path.resolve(__dirname, '../.logs/123.log'))
  .then(console.log)
  .catch(console.error);

fs.open = promisify(fs.open);

But if I put fs.open = promisify(fs.open) above invoking fs.truncate, my promise do not resolve or reject

fs.truncate = promisify(fs.truncate);
fs.open = promisify(fs.open);

fs.truncate(path.resolve(__dirname, '../.logs/123.log'))
  .then(console.log)
  .catch(console.error);

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.promisesIssues and PRs related to ECMAScript promises.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions