Skip to content

.setupHistory() for non-terminal REPL fails #36773

@addaleax

Description

@addaleax
  • Version: master
  • Platform: Ubuntu 20.04
  • Subsystem: repl

What steps will reproduce the bug?

'use strict';
const repl = require('repl');
const r = repl.start({ terminal: false });
r.setupHistory('/nonexistent/file', (err) => console.log(err));

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

No error (beyond the warning message)

What do you see instead?

$ node repltest.js 
> 
Error: Could not open history file.
REPL session history will not be persisted.
node:readline:794
                          StringPrototypeSlice(this.line, 0, this.cursor);
                          ^

TypeError: String.prototype.slice called on null or undefined
    at slice (<anonymous>)
    at REPLServer.Interface.getCursorPos (node:readline:794:27)
    at REPLServer.Interface._refreshLine (node:readline:419:26)
    at _writeToOutput (node:internal/repl/history:30:8)
    at oninit (node:internal/repl/history:69:7)
    at FSReqCallback.oncomplete (node:fs:184:23)
    at FSReqCallback.callbackTrampoline (node:internal/async_hooks:131:14)

Metadata

Metadata

Assignees

No one assigned

    Labels

    replIssues and PRs related to the REPL subsystem.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions