Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 02FDD200BFB for ; Wed, 28 Dec 2016 00:57:00 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 019C6160B3D; Tue, 27 Dec 2016 23:57:00 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 47EDD160B31 for ; Wed, 28 Dec 2016 00:56:59 +0100 (CET) Received: (qmail 98119 invoked by uid 500); 27 Dec 2016 23:56:58 -0000 Mailing-List: contact dev-help@thrift.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@thrift.apache.org Delivered-To: mailing list dev@thrift.apache.org Received: (qmail 98103 invoked by uid 99); 27 Dec 2016 23:56:58 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Dec 2016 23:56:58 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 5207D2C03DE for ; Tue, 27 Dec 2016 23:56:58 +0000 (UTC) Date: Tue, 27 Dec 2016 23:56:58 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: dev@thrift.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (THRIFT-4010) Q.fcall messing up with *this* pointer inside called function MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 27 Dec 2016 23:57:00 -0000 [ https://issues.apache.org/jira/browse/THRIFT-4010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15781565#comment-15781565 ] ASF GitHub Bot commented on THRIFT-4010: ---------------------------------------- Github user asfgit closed the pull request at: https://github.com/apache/thrift/pull/1143 > Q.fcall messing up with *this* pointer inside called function > ------------------------------------------------------------- > > Key: THRIFT-4010 > URL: https://issues.apache.org/jira/browse/THRIFT-4010 > Project: Thrift > Issue Type: Bug > Components: Node.js - Compiler > Affects Versions: 0.9.3 > Reporter: Bruno Fonseca > Fix For: 0.10.0 > > > Example: I define a basic service > ``` > namespace js Auth > service AuthSrv { > string signin( > 1:string email, > 2:string password > ) > } > ``` > And set up a Auth es6 class that gonna handle the requests like this: > ``` > module.exports = class AuthSrv { > constructor() { > this.db = ......... > } > async signin(email, password) { > try { > let user = await this.db.findOne(....) > } > > .... > } > } > ``` > and instantiate a thrift server like this: > ``` > let server = thrift.createServer(AuthProcessor, new AuthSrv()); > ``` > In this scenario, i'm getting that *this* pointer is **undefined** when signin function is called. Looking at thrift generated code for the processor i saw this line: > ``` > if (this._handler.signin.length === 2) { > Q.fcall(this._handler.signin, args.email, args.password) > .then(.....) > } > ``` > If i change the fcall to: > ``` > if (this._handler.signin.length === 2) { > Q.fcall(this._handler.signin.bind(this._handler), args.email, args.password) > .then(.....) > } > ``` > everything works like a charm and *this* pointer is correctly assinged inside signin function call. -- This message was sent by Atlassian JIRA (v6.3.4#6332)