GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — net: `write(cb)` not called if `destroy()`:ed before `'connect'` · Issue #30841 · nodejs/node

net: write(cb) not called if destroy():ed before 'connect' #30841

New issue
Copy link
New issue
Copy link
Closed
#45922
Closed
net: write(cb) not called if destroy():ed before 'connect'#30841
#45922
Copy link
Labels
confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.netIssues and PRs related to the net subsystem.Issues and PRs related to the net subsystem.

Description

@ronag
ronag
opened on Dec 7, 2019
Issue body actions

See #30839

_writeGeneric waits for 'connect'

node/lib/net.js

Line 759 in cf5ce2c

this.once('connect', function connect() {
which might never be emitted due to

node/lib/net.js

Lines 1106 to 1108 in cf5ce2c

if (self.destroyed) {
return;
}

I believe this will fail:

const socket = createSocketBeforeConnect();
socket.write('asd', common.mustCall());
socket.destroy();

Activity

  1. ronag
    changed the title [-]net: write(cb) not called if destroyed[/-] [+]net: `write(cb)` not called if `destroy()`:ed before 'connect'[/+] on Dec 7, 2019
  2. ronag
    changed the title [-]net: `write(cb)` not called if `destroy()`:ed before 'connect'[/-] [+]net: `write(cb)` not called if `destroy()`:ed before `'connect'`[/+] on Dec 7, 2019
  3. lpinca
    added
    netIssues and PRs related to the net subsystem.Issues and PRs related to the net subsystem.
    on Dec 7, 2019
  4. ronag commented on Jan 3, 2020

    @ronag
    ronag
    on Jan 3, 2020
    MemberAuthor
    More actions

    This is fixed

  5. ronag
    closed this as completedon Jan 3, 2020
  6. lpinca commented on Jan 5, 2020

    @lpinca
    lpinca
    on Jan 5, 2020
    Member
    More actions

    If the expectation is that callback is called this is not fixed.

    const assert = require('assert');
    const net = require('net');
    
    const socket = new net.Socket();
    
    socket.connect({
      port: 80,
      host: 'example.com',
      lookup() {}
    });
    
    assert(socket.connecting);
    
    let called = false;
    
    socket.write('foo', function() {
      called = true;
    });
    
    socket.destroy();
    
    process.on('exit', function() {
      assert(called);
    });
    Reacted by Robert Nagy
  7. lpinca
    reopened this on Jan 5, 2020
  8. ronag commented on Jan 5, 2020

    @ronag
    ronag
    on Jan 5, 2020
    MemberAuthor
    More actions

    Yea, we should add a test for that.

    This seems related to the whole constructing state which in this case never gets resolved, i.e. _write never finishes https://github.com/nodejs/node/blob/master/lib/net.js#L763. I can dig into this once/if #29656 lands.

  9. lpinca commented on Jan 5, 2020

    @lpinca
    lpinca
    on Jan 5, 2020
    Member
    More actions

    yes, _writeGeneric() is never called as 'connect' is never emitted.

    Reacted by Robert Nagy
  10. ronag commented on Jan 6, 2020

    @ronag
    ronag
    on Jan 6, 2020
    MemberAuthor
    More actions

    pending resolution to discussion in #31179

  11. ronag commented on Apr 19, 2020

    @ronag
    ronag
    on Apr 19, 2020
    MemberAuthor
    More actions
    'use strict';
    
    const common = require('../common');
    const assert = require('assert');
    const net = require('net');
    
    const socket = new net.Socket();
    
    socket.connect({
      port: 80,
      host: 'example.com',
      lookup() {}
    });
    
    assert(socket.connecting);
    
    socket.write('foo', common.mustCall());
    socket.destroy();
  12. ronag commented on Apr 19, 2020

    @ronag
    ronag
    on Apr 19, 2020
    MemberAuthor
    More actions

    This requires #29656 in order to be fully resolved.

  13. ronag
    added
    confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.
    on Apr 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.netIssues and PRs related to the net subsystem.Issues and PRs related to the net subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.